sp=script.Parent function waitfor(a,s)while a:FindFirstChild(s)==nil do a.ChildAdded:wait()end return a:FindFirstChild(s)end reloading=waitfor(sp,"\082\101\108\111\097\100\105\110\103")down=waitfor(sp,"\077\111\117\115\101\068\111\119\110")runanim=waitfor(sp,"\082\117\110\065\110\105\109")animspeed=1.2 equipspeed=1.5 originalgrip=CFrame.new(0,0,-1.1,0,0,1,1,0,0,0,1,0)currentgrip=originalgrip function swordUp()currentgrip=originalgrip sp.Grip=currentgrip end function swordOut()currentgrip=originalgrip*CFrame.Angles(math.pi/4,.4,0)sp.Grip=currentgrip end function spinsword(a)delay(0,function()local s=tick()local z=s+a while tick()<z do sp.Grip=currentgrip*CFrame.Angles((math.pi*2)*((tick()-s)/a),0,0)wait()end sp.Grip=currentgrip end)end function update(a)if a~=nil then if reloading.Value then 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\087\097\105\116\067\117\114\115\111\114\046\112\110\103"else 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"end end end runanim.Changed:connect(function()local a=sp.Parent:FindFirstChild("\072\117\109\097\110\111\105\100")local s=sp.Parent:FindFirstChild("\084\111\114\115\111")local z=sp:FindFirstChild(runanim.Value)if z and(s and a)then local s=a:LoadAnimation(z)if s and a.Health>0 then s:Play(nil,nil,animspeed)end end end)function Equipped(a)if a~=nil then update(a)reloading.Changed:connect(function()update(a)end)a.Button1Down:connect(function()down.Value=true end)a.Button1Up:connect(function()down.Value=false end)local s=sp.Parent:FindFirstChild("\072\117\109\097\110\111\105\100")local z=sp.Parent:FindFirstChild("\084\111\114\115\111")if z and s then local a=sp:FindFirstChild("\069\113\117\105\112")if a~=nil then local z=s:LoadAnimation(a)if z and s.Health>0 then z:Play(nil,nil,equipspeed)end end local z=sp:FindFirstChild("\072\111\108\100")if z~=nil then if HoldAnim then HoldAnim:Stop()end HoldAnim=s:LoadAnimation(z)if HoldAnim and s.Health>0 then HoldAnim:Play()end end end end end function Unequipped()down.Value=false if HoldAnim then HoldAnim:Stop()end end sp.Equipped:connect(Equipped)sp.Unequipped:connect(Unequipped)



sp=script.Parent


function waitfor(a,b)
	while a:FindFirstChild(b)==nil do
		a.ChildAdded:wait()
	end
	return a:FindFirstChild(b)
end

reloading=waitfor(sp,"Reloading")
down=waitfor(sp,"MouseDown")
runanim=waitfor(sp,"RunAnim")

animspeed=1.2		--lower number is slower
equipspeed=1.5
originalgrip=CFrame.new(0,0,-1.1,0,0,1,1,0,0,0,1,0)
currentgrip=originalgrip
function swordUp()
	currentgrip=originalgrip
	sp.Grip=currentgrip
end
function swordOut()
	currentgrip=originalgrip*CFrame.Angles(math.pi/4,.4,0)
	sp.Grip=currentgrip
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

function update(mouse)
	if mouse~=nil then
		if reloading.Value then
			mouse.Icon="rbxasset://textures\\GunWaitCursor.png"
		else
			mouse.Icon="rbxasset://textures\\GunCursor.png"
		end
	end
end

runanim.Changed:connect(function()
	local h=sp.Parent:FindFirstChild("Humanoid")
	local t=sp.Parent:FindFirstChild("Torso")
	local anim=sp:FindFirstChild(runanim.Value)
	if anim and t and h then
		local theanim=h:LoadAnimation(anim)
		if theanim and h.Health>0 then
			theanim:Play(nil,nil,animspeed)
		end
	end
end)


function Equipped(mouse)
	if mouse~=nil then
		update(mouse)
		reloading.Changed:connect(function()
			update(mouse)
		end)
		mouse.Button1Down:connect(function()
			down.Value=true
		end)
		mouse.Button1Up:connect(function()
			down.Value=false
		end)
		local h=sp.Parent:FindFirstChild("Humanoid")
		local t=sp.Parent:FindFirstChild("Torso")
		if t and h then
			local equipanim=sp:FindFirstChild("Equip")
			if equipanim~=nil then
				local EquipAnim=h:LoadAnimation(equipanim)
				if EquipAnim and h.Health>0 then
					EquipAnim:Play(nil,nil,equipspeed)
				end
			end
			local holdanim=sp:FindFirstChild("Hold")
			if holdanim~=nil then
				if HoldAnim then
					HoldAnim:Stop()
				end
				HoldAnim=h:LoadAnimation(holdanim)
				if HoldAnim and h.Health>0 then
					HoldAnim:Play()
				end
			end
		end
	end
end

function Unequipped()
	down.Value=false
	if HoldAnim then
		HoldAnim:Stop()
	end
end

sp.Equipped:connect(Equipped)
sp.Unequipped:connect(Unequipped)
