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 4 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

--//Animations
local facepalm = Instance.new("Animation")
facepalm .AnimationId = "http://www.roblox.com/Asset?ID=3291600803"
local animTrack = p.Character.Humanoid:LoadAnimation(facepalm)

script.Parent.MouseButton1Click:Connect(function()
print("Facepalm played")
animTrack:Play()

end)`

Thanks for helping

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

2 answers

Log in to vote
0
Answered by 4 years ago

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

local player = game.Players.LocalPlayer
local facepalm = Instance.new("Animation")
facepalm.AnimationId = "3291600803"
local animTrack = player.Character.Humanoid:LoadAnimation(facepalm)

script.Parent.MouseButton1Click:Connect(function()
    animTrack:Play()
end)

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:

local player = game.Players.LocalPlayer
local debounce = false
local facepalm = Instance.new("Animation")
facepalm.AnimationId = "3291600803"
local animTrack = player.Character.Humanoid:LoadAnimation(facepalm)

script.Parent.MouseButton1Click:Connect(function()
    if debounce == false then -- if debounce is true, it's that the animation is playing
        debounce = true
        animTrack:Play()
        wait(-- PUT HERE YOUR ANIMATION'S DURATION)
        debounce = false
    end
end)

Hope this helped!

0
Thank you for answering, i did the following: sinbadxfan05 3 — 4y
Ad
Log in to vote
0
Answered by 4 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)

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

`

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

Answer this question