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

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

Asked by 10 years ago

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

Log in to vote
1
Answered by 10 years ago

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)

Ad

Answer this question