Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

What's wrong with this animation script? it worked for the yt guy!

Asked by 3 years ago

ive never worked with animations

script.Parent.MouseButton1Click:Connect(function()
local humnoid = game.Players.LocalPlayer.Character.Humanoid
local anom = humnoid:LoadAnimation(script:findFirstChild('Animation'))
    anom:Play() 
end) --localscript

i really have no idea I even watched a guy on youtube it worked for him but why not for me?

3 answers

Log in to vote
0
Answered by 3 years ago

You forgot the capital F in :FindFirstChild('Animation').

0
it works with the small one too TheEagle722 170 — 3y
0
Did you use the youtubers animation when its uncopylocked? CandyWreckEpicness 115 — 3y
0
If you did, you have to make your own. CandyWreckEpicness 115 — 3y
0
i used my own TheEagle722 170 — 3y
View all comments (3 more)
0
Did you create it correctly or did you call it "Animation"? CandyWreckEpicness 115 — 3y
0
both. TheEagle722 170 — 3y
0
Oh I just realized you put humnoid not humanoid. CandyWreckEpicness 115 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

Humanoid:LoadAnimation() is deprecated. Insert an Animator into the humanoid, and try using

Animator:LoadAnimation()

https://developer.roblox.com/en-us/api-reference/function/Humanoid/LoadAnimation

https://developer.roblox.com/en-us/api-reference/function/Animator/LoadAnimation

Log in to vote
0
Answered by 3 years ago

Like Omq_ItsJazmin said, Humanoid:LoadAnimation() is deprecated.

-- instead of this --

local humanoid = game.Players.LocalPlayer.Character.Humanoid
local anim = humanoid:LoadAnimation()
anim:Play()
-- do this --

local player = game.Player.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")


local Track = humanoid.Animator:LoadAnimation(--Your Animation Instance --)
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.

Answer this question