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

How come I keep getting an error on Humanoid for LoadAnimation?

Asked by 7 years ago
Edited 7 years ago

Whenever I try to test the code I made (do an animation while summoning a fireball), the output says that " LoadAnimation requires the Humanoid object (Player1.Humanoid) to be a descendant of the game object" Any ideas why and house to fix it. and I am sorry that I dont understand very well... I just started scripting 4 days ago. Here is my code..

animation.AnimationId = "http://www.roblox.com/asset/?id=853522647" -- ex http.robloxblahblah
local animTrack = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(animation)

game:GetService("UserInputService").InputBegan:connect(function(input)
    if input.KeyCode == Enum.KeyCode.E then 
    animTrack:Play()
    end
end) 

1 answer

Log in to vote
2
Answered by 7 years ago

If you started scripting 4 days ago, I better not help because you should learn the basics before advancing. I'm not going to explain much but first here are some steps;

  1. Create an object called Animation and place it in **ServerStorage** Or ReplicatedStorage
  2. Make sure the animation has the correct Id

If you followed those steps then good, I'm not going to help you make your script though, you will have to learn where to place certain things for your own good.

First, make a variable for the animation

so do this;

local animation = game.ReplicatedStorage:WaitForChild('Animation') --Change to serverStorage or change animation name

Now you load the animation into the humanoid;

local humanoid = game.Players.LocalPlayer:WaitForChild('Character').Humanoid -- make sure you have the humanoid first

Now lastly UserInputService;

local humanoid = game.Players.LocalPlayer:WaitForChild('Character').Humanoid -- make sure you have the humanoid first
local animation = game.ReplicatedStorage:WaitForChild('Animation') --Change to serverStorage or change animation name

game:GetService("UserInputService").InputBegan:connect(function(input)
    if input.KeyCode == Enum.KeyCode.E then
        local animTrack = Humanoid:LoadAnimation(animation)
        animTrack:Play()
    end
end)

For more info; http://wiki.roblox.com/index.php?title=Animations

If this helped then please accept answer. And to be honest, it's rare for people to help with these question.

Good luck.

0
Re do it over again foxingaround9 -5 — 7y
0
Tyvm! I should of closed this question though because I fixed my script beforehand and I finally got my animations to work. Thank you very much though! Im a fast learner btw ???? iizWishzii 21 — 7y
0
Nice job BlackOrange3343 2676 — 7y
Ad

Answer this question