I am trying to play an animation when the user activates a tool. It prints to the console “Hello World”, but the animation won’t play.
I then tried putting the script alone and trying to make it run at server start, it worked, then I did that same thing but equipped the tool before the animation was supposed to play and it didn’t play.
How could I fix this?
My code:
function onActivated()
print("Playing Animation")
local player = game.Players.LocalPlayer
local Animation = Instance.new("Animation", player.Character)
Animation.AnimationId = "rbxassetid://myAnimationID"
local AnimationLoaded = player.Character.Humanoid:LoadAnimation(Animation)
AnimationLoaded:Play()
end
script.Parent.Activated:Connect(onActivated)
Basically, it didn’t say “Hello World”, it was just an example text but in the code there was written “Playing Animation”. It’s my habit of telling that code outputs hello world ¯\_(ツ)_/¯