local V=script.Parent local A=10 local T=CFrame.Angles(math.pi/2,0,0)+Vector3.new(0,-0.25,-1.4)local F=T local n=game:GetService("\068\101\098\114\105\115")local j=true local s=false local y=0 function waitfor(V,A)while true do local T=V:FindFirstChild(A)if T~=nil then return T end wait()end end waitfor(V,"\072\097\110\100\108\101")function onButton1Down(V)if not j then return end j=false V.Icon="\114\098\120\097\115\115\101\116\058\047\047\116\101\120\116\117\114\101\115\092\071\117\110\087\097\105\116\067\117\114\115\111\114\046\112\110\103"wait(.75)V.Icon="\114\098\120\097\115\115\101\116\058\047\047\116\101\120\116\117\114\101\115\092\071\117\110\067\117\114\115\111\114\046\112\110\103"j=true end function swordUp()F=T end function swordOut()F=T*CFrame.Angles(math.pi/4,.4,0)end function spinsword(A)delay(0,function()local T=tick()local n=T+A while tick()<n do V.Grip=F*CFrame.Angles((math.pi*2)*((tick()-T)/A),0,0)wait()end V.Grip=F end)end V.Equipped:connect(function(A)equipped=true local T=lastequipped if A==nil then print("\077\111\117\115\101 \110\111\116 \102\111\117\110\100")return end A.Icon="\114\098\120\097\115\115\101\116\058\047\047\116\101\120\116\117\114\101\115\092\071\117\110\067\117\114\115\111\114\046\112\110\103"A.Button1Down:connect(function()onButton1Down(A)end)waitfor(V,"\084\097\117\110\116\105\110\103")waitfor(V,"\084\097\117\110\116")end)V.Unequipped:connect(function()equipped=false end)waitfor(V,"\082\117\110\065\110\105\109")V.RunAnim.Changed:connect(function()local A=V.Parent:FindFirstChild("\072\117\109\097\110\111\105\100")local T=V.Parent:FindFirstChild("\084\111\114\115\111")local n=V:FindFirstChild(V.RunAnim.Value)if n and(T and A)then theanim=A:LoadAnimation(n)if theanim and A.Health>0 then theanim:Play()if V.RunAnim.Value=="\082\105\103\104\116\083\108\097\115\104"or V.RunAnim.Value=="\076\101\102\116\083\108\097\115\104"or V.RunAnim.Value=="\079\118\101\114\072\101\097\100\083\119\105\110\103"then spinsword(.5)end if V.RunAnim.Value=="\079\118\101\114\072\101\097\100\083\119\105\110\103"then wait(.25)swordOut()wait(.5)swordUp()V.Grip=F elseif V.RunAnim.Value=="\079\118\101\114\072\101\097\100\083\119\105\110\103\070\097\115\116"then wait(.125)swordOut()wait(.25)swordUp()V.Grip=F end end end end)function tagHumanoid(V,A)for V,A in ipairs(V:GetChildren())do if A.Name=="\099\114\101\097\116\111\114"then A:remove()end end local T=Instance.new("\079\098\106\101\099\116\086\097\108\117\101")T.Value=A T.Name="\099\114\101\097\116\111\114"T.Parent=V n:AddItem(T,1)end



local sp=script.Parent


local tauntcooldown=10

local originalgrip=CFrame.Angles(math.pi/2,0,0)+Vector3.new(0,-.25,-1.4)

local currentgrip=originalgrip

local debris=game:GetService("Debris")
local enabled=true
local taunting=false
local lasttaunt=0

function waitfor(parent,name)
	while true do
		local child=parent:FindFirstChild(name)
		if child~=nil then
			return child
		end
		wait()
	end
end

waitfor(sp,"Handle")

function onButton1Down(mouse)
	if not enabled then
		return
	end
	enabled=false
	mouse.Icon="rbxasset://textures\\GunWaitCursor.png"
	wait(.75)
	mouse.Icon="rbxasset://textures\\GunCursor.png"
	enabled=true
end

function swordUp()
	currentgrip=originalgrip
end

function swordOut()
	currentgrip=originalgrip*CFrame.Angles(math.pi/4,.4,0)
end

function spinsword(spintime)
	delay(0,function()
		local startspin=tick()
		local endspin=startspin+spintime
		while tick()<endspin do
			sp.Grip=currentgrip*CFrame.Angles(math.pi*2*((tick()-startspin)/spintime),0,0)
			wait()
		end
		sp.Grip=currentgrip
	end)
end

sp.Equipped:connect(function(mouse)
	equipped=true
	local currentlast=lastequipped
	if mouse==nil then
		print("Mouse not found")
		return 
	end
	mouse.Icon="rbxasset://textures\\GunCursor.png"
	mouse.Button1Down:connect(function()
		onButton1Down(mouse)
	end)
	waitfor(sp,"Taunting")
	waitfor(sp,"Taunt")
	--[[waitfor(sp,"Summon")
	mouse.KeyDown:connect(function(key)
		key=string.lower(key)
		if key=="l" or key=="t" or key=="g" or key=="e" then
			local h=sp.Parent:FindFirstChild("Humanoid")
			if h~=nil and (not sp.Taunting.Value) and lasttaunt+tauntcooldown<tick() then
				lasttaunt=tick()
				sp.Taunting.Value=true
				h.WalkSpeed=0
				tauntanim=h:LoadAnimation(sp.Taunt)
				tauntanim:Play()
				wait(4)
				sp.Summon.Value=not sp.Summon.Value
				wait(1)
				h.WalkSpeed=16
				sp.Taunting.Value=false
			end
		end
	end)
	--]]
end)

sp.Unequipped:connect(function()
	equipped=false
end)

waitfor(sp,"RunAnim")
sp.RunAnim.Changed:connect(function()
	local h=sp.Parent:FindFirstChild("Humanoid")
	local t=sp.Parent:FindFirstChild("Torso")
	local anim=sp:FindFirstChild(sp.RunAnim.Value)
	if anim and t and h then
		theanim=h:LoadAnimation(anim)
		if theanim and h.Health>0 then
			theanim:Play()
			if sp.RunAnim.Value=="RightSlash" or sp.RunAnim.Value=="LeftSlash" or sp.RunAnim.Value=="OverHeadSwing" then
				spinsword(.5)
			end
			if sp.RunAnim.Value=="OverHeadSwing" then
				wait(.25)
				swordOut()
				wait(.5)
				swordUp()
				sp.Grip=currentgrip
			elseif sp.RunAnim.Value=="OverHeadSwingFast" then
				wait(.125)
				swordOut()
				wait(.25)
				swordUp()
				sp.Grip=currentgrip
			end
		end
	end
end)

function tagHumanoid(humanoid,player)
	for i,v in ipairs(humanoid:GetChildren()) do
		if v.Name=="creator" then
			v:remove()
		end
	end
	local creator_tag=Instance.new("ObjectValue")
	creator_tag.Value=player
	creator_tag.Name="creator"
	creator_tag.Parent=humanoid
	debris:AddItem(creator_tag,1)
end

