local function E(E,J)while not E:FindFirstChild(J)do E.ChildAdded:wait()end return E[J]end local J=script.Parent local Z={}local y local p local function K(E)if Z[E]then Z[E]:Play()end end local function e(E)if Z[E]then Z[E]:Stop()end end function OnEquipped(e)p=J.Parent y=E(p,"\072\117\109\097\110\111\105\100")if y then Z.EquipAnim=y:LoadAnimation(E(J,"\069\113\117\105\112\065\110\105\109\053"))end K("\069\113\117\105\112\065\110\105\109")end function OnUnequipped()for E,J in pairs(Z)do e(E)end end J.Equipped:connect(OnEquipped)J.Unequipped:connect(OnUnequipped);(E(J,"\080\108\097\121\083\108\097\115\104")).Changed:connect(function(E)K("\083\108\097\115\104\065\110\105\109")end);(E(J,"\080\108\097\121\084\104\114\117\115\116")).Changed:connect(function(E)K("\084\104\114\117\115\116\065\110\105\109")end);(E(J,"\080\108\097\121\079\118\101\114\104\101\097\100")).Changed:connect(function(E)K("\079\118\101\114\104\101\097\100\065\110\105\109")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'))
	end
	PlayAnimation('EquipAnim')
end

function OnUnequipped()
	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
			PlayAnimation('OverheadAnim')
		--else
		--	StopAnimation('OverheadAnim')
		--end
	end)
