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

How do I make an animation play when a player clicks a TextButton?

Here is all I have so far:

local Animation = Instance.new("Animation")
Animation.AnimationId = "http://www.roblox.com/asset?id=154647208"

function PlayAnimation()
	--C0DE HERE PL0X
end

script.Parent.MouseButton1Down:connect(PlayAnimation)

How do I make the TextButton play the animation (and loop the animation) when it is clicked by a player? I have no clue how to work animations, and I really need help.

Thanks in advanced!

1 answer

✓ Accepted answer

You need to load the animation to the humanoid then play it. Use this in a local script. If you want to learn more about animations then go to the link below.

http://wiki.roblox.com/index.php?title=Animations

Player = game.Players.LocalPlayer
local Animation = Instance.new("Animation")
Animation.AnimationId = "http://www.roblox.com/asset?id=154647208"

function PlayAnimation()
local animTrack = Player.Character.Humanoid:LoadAnimation(Animation)
animTrack:Play()
end
script.Parent.MouseButton1Down:connect(PlayAnimation)

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