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

Start to play animation by clicking textbutton?

Asked by 5 years ago

Hey everyone, im trying to make a game like danceoff but the animations wont play when the buttons are clicked. Can somebody help me? This is how far i've come until now, but it doesnt work.

`local p = game.Players.LocalPlayer

01--//Animations
02local facepalm = Instance.new("Animation")
03facepalm .AnimationId = "http://www.roblox.com/Asset?ID=3291600803"
04local animTrack = p.Character.Humanoid:LoadAnimation(facepalm)
05 
06script.Parent.MouseButton1Click:Connect(function()
07print("Facepalm played")
08animTrack:Play()
09 
10end)`

Thanks for helping

0
Do you own the animation? If not then studio won't let you play it. Robowon1 323 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago

I don't know why it is not working, but did you put this in a LOCALSCRIPT? Also, change this:

1local player = game.Players.LocalPlayer
2local facepalm = Instance.new("Animation")
3facepalm.AnimationId = "3291600803"
4local animTrack = player.Character.Humanoid:LoadAnimation(facepalm)
5 
6script.Parent.MouseButton1Click:Connect(function()
7    animTrack:Play()
8end)

I just changed the animation ID. We don't need what that is before it. Also, localscripts cannot print things, so I deleted that printing line. If it doesn't work, is the localscript "Disabled" in its properties?

Also, I suggest you to add a debounce:

01local player = game.Players.LocalPlayer
02local debounce = false
03local facepalm = Instance.new("Animation")
04facepalm.AnimationId = "3291600803"
05local animTrack = player.Character.Humanoid:LoadAnimation(facepalm)
06 
07script.Parent.MouseButton1Click:Connect(function()
08    if debounce == false then -- if debounce is true, it's that the animation is playing
09        debounce = true
10        animTrack:Play()
11        wait(-- PUT HERE YOUR ANIMATION'S DURATION)
12        debounce = false
13    end
14end)

Hope this helped!

0
Thank you for answering, i did the following: sinbadxfan05 3 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

Well i tried what you said but now i get this: 19:20:08.004 - Invalid animation id '<error: unknown AssetId protocol>': the script: ` local player = game.Players.LocalPlayer local debounce = false local facepalm = Instance.new("Animation") facepalm.AnimationId = "3291600803" wait(3) local animTrack = player.Character.Humanoid:LoadAnimation(facepalm)

1script.Parent.MouseButton1Click:Connect(function()
2    if debounce == false then -- if debounce is true, it's that the animation is playing
3        debounce = true
4        script.Parent.Text = 'It works'
5        animTrack:Play()
6        wait(4)
7        debounce = false
8    end
9end)

`

0
Hi, I think what this output is saying is that your animation ID doesn't exists. TheRealPotatoChips 793 — 5y
0
Try to recopy its animation id TheRealPotatoChips 793 — 5y
0
yes i know how it works i had to try with another animation thx for th ehelp sinbadxfan05 3 — 5y

Answer this question