I created an animation and I want it to activate when a tool is equipped. Everything about the tool works fine, it is just that the animation does not play when I equip the tool. I have overlooked my code and my animation and I am almost certain everything is in place.
One odd thing that I found though is if I insert the tool with the script into another place of mine, it works perfectly. So, for some odd reason, this will just not work in the actual game I want it to work in.
Also, something important I should mention is that both places in question and the animation is owned by me. The place I want it to work in is a team create, but I am still the owner. Maybe I did not search well enough, but I could not find anyone else with this isuse.
Here is the code I have in the tool. It is in a LocalScript.
local tool = script.Parent
local player = game.Players.LocalPlayer
local anim = tool:WaitForChild("Animation")
tool.Equipped:Connect(function()
local char = player.Character
local huma = char:WaitForChild("Humanoid")
local animator = huma:FindFirstChildOfClass("Animator") or Instance.new("Animator", huma)
local PlayAnim = animator:LoadAnimation(anim)
PlayAnim:Play()
end)