I have recently been making a game, were you need to click a button to make an animation play however, I am having big trouble with doing so that the animation only plays once. How would I fix it? I have tried to add a wait() function in the end, however it doesn´t help on anything, the animation will still play multiple times if the player clicks the button again.
local hum = game.Workspace.Dannebrog.HumanoidCharacter local set = hum.Parent.Settings local sp = set.Speed local enabled = set.Enabled local ClickDetector = game.Workspace.FlagSign.Sign.ClickDetector local humanim = hum:LoadAnimation(hum.Parent.Settings.IdleAnimation) ClickDetector.MouseClick:Connect(function() humanim:Play() humanim.Looped = false humanim:AdjustSpeed(sp.Value) end)
local hum = workspace.Dannebrog.HumanoidCharacter local set = hum.Parent.Settings local sp = set.Speed local enabled = set.Enabled local ClickDetector = game.Workspace.FlagSign.Sign.ClickDetector local humanim = hum:LoadAnimation(hum.Parent.Settings.IdleAnimation) humanim.Looped = false -- placed before the event ClickDetector.MouseClick:Connect(function(player) if not humanim.IsPlaying then -- debounce, checking if animation is not playing, then executing code. humanim:AdjustSpeed(sp.Value) -- only place this here if sp.Value changes, if not place it before the event. humanim:Play() end end)