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
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.
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.