Animation only plays in Roblox Studio

I have this tool that plays animation when the tool is equipped. The animation plays in Roblox studio, but not when you’re playing the game. Does anyone know how to fix the problem?

local plr = game:GetService("Players").LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local h = char:WaitForChild("Humanoid")
local anim = h:LoadAnimation(script.Parent:WaitForChild("Animation"))

local Box = script.Parent

Box.Equipped:Connect(function()
 anim:Play()
end)

Box.Unequipped:Connect(function()
 anim:Stop()
end)

publish the animation as your animation and get the animation id. If this is a group game publish it as the group animation instead.

1 Like