I have a script that’s meant to play an animation on the LocalPlayer when they press a button, the debug print is saying that the animation plays in the output window, however it doesn’t work and the animation does not play. I can confirm that the animation ID is correct and works - any advice or help would be appreciated, I’m a beginner scripter by the way so I’m not too sure.
local click = script.Parent.MouseButton1Click
local players = game:GetService("Players")
local char = players.LocalPlayer.Character
if not char then
print("Waiting for character to load...")
players.LocalPlayer.CharacterAdded:Wait()
char = players.LocalPlayer.Character
end
local hum = char:WaitForChild("Humanoid")
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://17426012182"
local animationTrack = hum:LoadAnimation(animation)
function playAnimation()
print("Animation playing...")
animationTrack:Play()
end
click:Connect(playAnimation)
local hum = char:WaitForChild("Humanoid")
local animator = hum:FindFirstChild("Animator")
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://17426012182"
local animationTrack = animator:LoadAnimation(animation)
I believe the method of loading animation into humanoid has been deprecated and may have issues when done that way. You might have to create an Animator instance and parent it to Humanoid then load the animation into Animator the same way you would with the Humanoid.
To test this myself, I simply created a ScreenGui containing a TextButton, which then contain the script. I didn’t place the animation anywhere, since it is generated by the script.