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
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!
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)
`