Script works in studio but not in game

title ^

script.Parent.Equipped:Connect(function(Mouse)
	Mouse.Button1Down:Connect(function()
		animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation)
		animation:Play()
	end)
end)

script.Parent.Unequipped:Connect(function()
	animation:Stop()
end)
1 Like

Is the Animation owned by you? If it isn’t, then I believe it can’t be able to be played within your game

Also use the Tool.Activated Event instead for this, there isn’t a necessity to be checking 2 functions inside of each other

local Tool = script.Parent
local Plr = game.Players.LocalPlayer
local Chr = Plr.Character or Plr.CharacterAdded:Wait()
local Animator = Chr:WaitForChild("Humanoid"):WaitForChild("Animator")
local Animation

Tool.Activated:Connect(function()
    Animation = Animator:LoadAnimation(Tool.Animation)
    Animation:Play()
end)

Tool.Unequipped:Connect(function()
    Animation:Stop()
end)

Otherwise, I’d check to see what your AnimationPriority is set as cause that may be overlapping with your other default animations

2 Likes

The Animation you try to load needs to be owner by the user or group that owns the game.

1 Like

I didn’t try either of these solutions yet but I am going to rn. Quick question first tho is it a problem that the animations is owned by me but its a group game?

Yes
That is most likely the issue

1 Like

Okay thank you I will try and test these suggestions tomorrow!

FYI: If you don’t own an animation, it’s really likely to not work in your game(s).

I fixed it now I just had to add it to the group instead of myself. It was owned by me but even though I owned the group it was in it didn’t work because it was owned by me and not the group.