Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Animation wont Run?

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

✓ Accepted answer
  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!

2 comments

0

Thanks Dude :D

0

You're welcome.

This discussion is preserved as it was. New answers, comments, and votes are closed.