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

Can somebody help? I want to make a GUI that when you click you do an animation.

Asked by 10 years ago

function onClicked(click) local animation = Instance.new("Animation") animation.AnimationId = "http://www.roblox.com/Asset?ID=144884906" end

1 answer

Log in to vote
0
Answered by 10 years ago

Put this inside the button (it needs to be a localscript, or it won't work)

local player = game.Players.LocalPlayer
repeat wait() until player.Character -- wait until their character exists
local anim = Instance.new("Animation") -- make a new animation
animation.AnimationId = "http://www.roblox.com/Asset?id=144884906" -- set the animation's id
local animation = player.Character.Humanoid:LoadAnimation(anim) -- load the animation

function onClicked() 
    animation:Play() -- play the animation
end

script.Parent.MouseButton1Down:connect(onClicked)

P.S. Next time, put your code inside the code (~~~~~~~~~~~~~~~~~) tags.

0
Thnxs iiLordy 0 — 10y
0
Didn't work iiLordy 0 — 10y
0
Where do I put the animation? iiLordy 0 — 10y
0
You don't put the animation anywhere.. it creates it for you. Thewsomeguy 448 — 10y
Ad

Answer this question