So Im working on a crouch system, and in a while loop it constantly checks if the player is crouching. But how (in that while loop) can I play an animation without the animation looping playing? Because then it only plays the start of the animation.
just add a variable like “alreadydone” or something
local alreadydone = false while wait() do if not alreadydone then print("done") alreadydone = true end end
You can use an event like this, with anim being your crouch animation:
local animationTrack1 = humanoid:LoadAnimation(anim) animationTrack1:GetMarkerReachedSignal("end"):Connect(function(paramString) --[[ other code here maybe here you can call an event... make this event based, for when player has crouched , instead of running a loop, which will probably reduce lag ]]-- animationTrack1:Stop() end) animationTrack1:Play()
you can use break to end the while loop, or a for loop.
while wait() do if good then break -- stops the loop end end