local function o(o,p)while not o:FindFirstChild(p)do o.ChildAdded:wait()end return o[p]end local p=script.Parent local O={}local K local T local function y(o)if O[o]then O[o]:Play()end end local function a(o)if O[o]then O[o]:Stop()end end function OnEquipped(a)T=p.Parent K=o(T,"\072\117\109\097\110\111\105\100")if K then O.EquipAnim=K:LoadAnimation(o(p,"\069\113\117\105\112\065\110\105\109\053"))O.IdleAnim=K:LoadAnimation(o(p,"\073\100\108\101\065\110\105\109\051"))O.OverheadAnim=K:LoadAnimation(o(p,"\079\118\101\114\104\101\097\100\065\110\105\109\050"))O.SlashAnim=K:LoadAnimation(o(p,"\083\108\097\115\104\065\110\105\109\050"))O.ThrustAnim=K:LoadAnimation(o(p,"\084\104\114\117\115\116\065\110\105\109\050"))O.UnequipAnim=K:LoadAnimation(o(p,"\085\110\101\113\117\105\112\065\110\105\109\050"))end O.EquipAnim:Play(.1,.8,1)y("\073\100\108\101\065\110\105\109")end function OnUnequipped()p.Handle.deactivate:Play()for o,p in pairs(O)do a(o)end end p.Equipped:connect(OnEquipped)p.Unequipped:connect(OnUnequipped);(o(p,"\080\108\097\121\083\108\097\115\104")).Changed:connect(function(o)y("\083\108\097\115\104\065\110\105\109")end);(o(p,"\080\108\097\121\084\104\114\117\115\116")).Changed:connect(function(o)y("\084\104\114\117\115\116\065\110\105\109")end);(o(p,"\080\108\097\121\079\118\101\114\104\101\097\100")).Changed:connect(function(o)O.OverheadAnim:Play()end)

local function WaitForChild(parent, childName)
	while not parent:FindFirstChild(childName) do parent.ChildAdded:wait() end
	return parent[childName]
end

local Tool = script.Parent

local Animations = {}
local MyHumanoid
local MyCharacter


local function PlayAnimation(animationName)
	if Animations[animationName] then
		Animations[animationName]:Play()
	end
end

local function StopAnimation(animationName)
	if Animations[animationName] then
		Animations[animationName]:Stop()
	end
end


function OnEquipped(mouse)
	MyCharacter = Tool.Parent
	MyHumanoid = WaitForChild(MyCharacter, 'Humanoid')
	if MyHumanoid then
		Animations['EquipAnim'] = MyHumanoid:LoadAnimation(WaitForChild(Tool, 'EquipAnim5'))
		Animations['IdleAnim'] = MyHumanoid:LoadAnimation(WaitForChild(Tool, 'IdleAnim3'))
		Animations['OverheadAnim'] = MyHumanoid:LoadAnimation(WaitForChild(Tool, 'OverheadAnim2'))
		Animations['SlashAnim'] = MyHumanoid:LoadAnimation(WaitForChild(Tool, 'SlashAnim2'))
		Animations['ThrustAnim'] = MyHumanoid:LoadAnimation(WaitForChild(Tool, 'ThrustAnim2'))
		Animations['UnequipAnim'] = MyHumanoid:LoadAnimation(WaitForChild(Tool, 'UnequipAnim2'))
	end

	Animations['EquipAnim']:Play(.1,.8,1)
	PlayAnimation('IdleAnim')
end

function OnUnequipped()
	Tool.Handle.deactivate:Play()
	for animName, _ in pairs(Animations) do
		StopAnimation(animName)
	end
end

Tool.Equipped:connect(OnEquipped)
Tool.Unequipped:connect(OnUnequipped)

WaitForChild(Tool, 'PlaySlash').Changed:connect(
	function (value)
		--if value then
			PlayAnimation('SlashAnim')
		--else
		--	StopAnimation('SlashAnim')
		--end
	end)

WaitForChild(Tool, 'PlayThrust').Changed:connect(
	function (value)
		--if value then
			PlayAnimation('ThrustAnim')
		--else
		--	StopAnimation('ThrustAnim')
		--end
	end)

WaitForChild(Tool, 'PlayOverhead').Changed:connect(
	function (value)
		--if value then
			Animations['OverheadAnim']:Play()
		--else
		--	StopAnimation('OverheadAnim')
		--end
	end)
