ive never worked with animations
1 | script.Parent.MouseButton 1 Click:Connect( function () |
2 | local humnoid = game.Players.LocalPlayer.Character.Humanoid |
3 | local anom = humnoid:LoadAnimation(script:findFirstChild( 'Animation' )) |
4 | anom:Play() |
5 | end ) --localscript |
i really have no idea I even watched a guy on youtube it worked for him but why not for me?
You forgot the capital F in :FindFirstChild('Animation').
Humanoid:LoadAnimation()
is deprecated. Insert an Animator into the humanoid, and try using
1 | Animator:LoadAnimation() |
https://developer.roblox.com/en-us/api-reference/function/Humanoid/LoadAnimation
https://developer.roblox.com/en-us/api-reference/function/Animator/LoadAnimation
Like Omq_ItsJazmin said, Humanoid:LoadAnimation()
is deprecated.
1 | -- instead of this -- |
2 |
3 | local humanoid = game.Players.LocalPlayer.Character.Humanoid |
4 | local anim = humanoid:LoadAnimation() |
5 | anim:Play() |
1 | -- do this -- |
2 |
3 | local player = game.Player.LocalPlayer |
4 | local character = player.Character or player.CharacterAdded:Wait() |
5 | local humanoid = character:WaitForChild( "Humanoid" ) |
6 |
7 |
8 | local Track = humanoid.Animator:LoadAnimation( --Your Animation Instance --) |
9 | Track:Play() |
So basically Let me explain why you should do this way. The player's character may have not loaded yet, so instead of doing player.Character
do player.Character or player.CharacterAdded:Wait()
also, :WaitForChild()
is extremely important when catching the player's character.