local bussy = false local lastSlasj = tick() local player = game.Players.LocalPlayer local char = player.Character wait(1) local aims = { ["idle"] = nil } script.Parent.Equipped:Connect(function() local char = player.Character aims.idle = Enum.AnimationPriority.Idle aims.idle = char.Humanoid:LoadAnimation(script.Parent.idle) aims.idle:Play() end)
When you call the AnimationPlayer (anim.idle) you need to have this predefined, because every time you equip the tool, the animation will be loaded again and you won't be able to stop it with another function except the .Equipped
event you first created it in.
It is also probably better to name your variable something without a period in its name, since the period denotes the hierarchy of the variable you are going to call.
You also defined "aims.idle" twice, so the second definition will override the first. Since the first definition is a property (Priority), you can define this after setting the variable.
LocalScript
local bussy = false local lastSlasj = tick() local player = game.Players.LocalPlayer local char = workspace:WaitForChild(player.Name) wait(1) local aims = {["idle"] = nil} local animPlayer = char.Humanoid:LoadAnimation(script.Parent.idle) animPlayer.Priority = Enum.AnimationPriority.Idle script.Parent.Equipped:Connect(function() animPlayer:Play() end) script.Parent.Unequipped:Connect(function() animPlayer:Stop() end)