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?
You forgot the capital F in :FindFirstChild('Animation').
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
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.