Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why is this animation track still able to be spammed?

I want them to have to wait for the animation to end before being able to repeat it, I don't want to use a wait statement as players can change which animation/emote they are doing and they have different lengths.

local function onDabUp(player)
	local Character = player.Character
	local Humanoid = Character:WaitForChild("Humanoid")
	local Animation = Character.Animation
	local Track = Humanoid:LoadAnimation(Animation)
		if not Track.IsPlaying then
		Track:Play()	
		else
	end
end

1 answer

✓ Accepted answer

In this function, you loaded the animation everytime it was executed. That means, everytime you execute the function, a new AnimationTrack would be created and it will be like another animation on its own, so even if you checked if it’s playing or not, it will always be false since it have no relation with the AnimationTrack that was created before which is probably playing. What you want to do here is to load the animation once, by moving the line that you defined the AnimationTrack (local Track ...) outside of the function. Also remember to use different variable names if you have multiple animations in one script.

Hope this helps.

This discussion is preserved as it was. New answers, comments, and votes are closed.