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

My animation will not play when the character loads. Could someone help me?

Asked by 4 years ago

Ok, so I was working on a script that will make an animation play when I player's character is loaded. I have placed the script in three places, Server Script Service, StaterPlayer, and in the workspace. However, when I placed the script into workspace it printed what I needed it to print, but it did not work, here's the error: 12:16:41.452 - LoadAnimation requires the Humanoid object (Ruflixx.Humanoid) to be a descendant of the game object

And, here's the script:




game.Players.PlayerAdded:Connect(function(p) print(p.Name) p.CharacterAdded:Connect(function(c) print(c.Name) local a = script.Animation:Clone() a.AnimationId = script.Animation.AnimationId a.Parent = c local humanoid = c.Humanoid local dance = humanoid:LoadAnimation(a) dance.Looped = true dance:Play() end) end)

keep in mind the script is currently in the workspace, thx <3

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

I added something to make sure the character's parent is the workspace.

Also, it's not really required to clone the script. Since you just load the ID into the humanoid, it can be used without cloning.

Try it with the following script and let me know what it does ^w^

game.Players.PlayerAdded:Connect(function(p)
    print(p.Name)
    p.CharacterAdded:Connect(function(c)
        while c.Parent == nil do --Wait until the character's parent is the workspace
            c.AncestryChanged:wait()
        end
        print(c.Name)
        local a = script.Animation
        local humanoid = c:WaitForChild("Humanoid")
        local dance = humanoid:LoadAnimation(a)
        dance.Looped = true
        dance:Play()
    end)
end)

Ad

Answer this question