How to prevent remote event from firing multiple times when in a loop?

I’m trying to make my character ragdoll and take fall damage when falling from heights, but I am doing the fall checking on the client and sending remotes to the server to register damage for maximum speed(I’m comparing userIds to make sure the remotes sent are from the player falling). But in order for me to be able to ragdoll I have to check how long they have been falling while they are falling, but since its a loop it would mean that my ragdoll remote would be fired dozens of times before landing, how could I solve this? Here is the client script:

local fallTime = 0

while true do
	x = wait()
	if script.Parent.Parent.Torso.Velocity.Y <= -10 then --Finds whether or not the player has begun falling and starts a timer
		print("Im falling!! :(")
		fallTime = fallTime + x
		if fallTime >= 0.5 then
			print("gonna fire a remote here eventually")
		end
	end
	if script.Parent.Parent.Torso.Velocity.Y > -10 then --Finds when the player has stopped falling
		if fallTime >= 0.6 then --Finds whether or not the player has been falling long enough to take damage
			fallRemote:FireServer(fallTime, "Damage") --Deals damage directly proportional to falling time; can simply change the 50 to another factor balance it differently
		end
		fallTime = 0
	end
end

You can add a variable i.e. landed. If character is falling you can set it to false, if they landed you can set it to true.

But how would I check when its changed without using a number value or checking constantly?

Doesn’t this part help you with that?

Without checking constantly, what you can do is use the Humanoid States
https://developer.roblox.com/en-us/api-reference/enum/HumanoidStateType

Also, if you’re interested in using another method:

There are a few about fall damage.

I can’t use stateTypes for fall damage with my ragdoll, it would cause no damage to be registered if you ragdolled while falling. Velocity is my only option as far as I know.

I’m just going to use a debounce on the server side for now until I find a better solution, thanks for trying to help.

You’re welcome. You don’t have to close it so quick, there may be others willing to help.

But if you just need to fire the event once, you can just add if falling then set variable falling to true.

and once

and falling is true, you set it back to false.

Yes I understand that but how would I check the value without using stateChanged, the only way I can think of to check the value is to constantly be checking it with runservice or a while loop, but wouldn’t that still fire the remote more than once?

No, unless I am misunderstanding what you mean by more than once. Does your script fall more than once during a ‘single’ fall, i.e. fall and lands then somehow fall and lands again.

You want it to ‘land’ only once right? therefore firing the remote only once.

Wait you are right, I was overthinking what you said but I figured it out, thanks for the help!