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

Animation wont Run?

Asked by
22To 70
9 years ago

I want this animation to run onenter and stay running... but when i try it fails to work. Yes i have made my own animation so this works..

Here is my lame attempt

onEnter
FindfirstChild:StarterPack.LocalScript
local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/Asset?ID=222080965"
animtrack:play

1 answer

Log in to vote
1
Answered by 9 years ago
  1. What is onEnter?
  2. FindFirstChild is a function, not a property
  3. You can't just say StarterPack.
  4. You need to load the animation in the humanoid
  5. Functions need "()"s at the end.

I'm guessing onEnter means when the player enters. So we use PlayerAdded.

game.Players.PlayerAdded:connect(function(player)
    print(player.Name) --Prints the player's name.
end)

FindFirstChild is a function,

game.StarterPack:FindFirstChild()

You cannot say StarterPack by itself as if it's script or game.

game.StarterPack

game:GetService("StarterPack")

You need to load the animation first.

workspace.Player1.Humanoid:LoadAnimation(animation)

Functions like "play" need "()"s at the end.

animation:play()

Now we add this all together

game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
        local script = game.StarterPack.LocalScript
        if character:FindFirstChild("Humanoid") then
            local animation = Instance.new("Animation")
            animation.AnimationId = "http://www.roblox.com/Asset?ID=222080965"
            local animtrack = character.Humanoid:LoadAnimation(animation)
            animtrack:play()
        end
    end)
end)


Hope this helps!

0
Thanks Dude :D 22To 70 — 9y
0
You're welcome. EzraNehemiah_TF2 3552 — 9y
Ad

Answer this question