I have a fall damage script in my game. This is the code.
hum.FreeFalling:Connect(function(newstate)
if newstate then
playerHeight = char.HumanoidRootPart.Position.Y
elseif not newstate then
local fallheight = playerHeight - char.HumanoidRootPart.Position.Y
if fallheight - minheight >= 1 then
local dmg = (fallheight - minheight)*dmgperstud
if dmg >= ragdolldmg then
if dmg >= injurydmg then
falldmg(dmg,true,true)
else
falldmg(dmg,false,true)
end
falldmg(dmg,false,true)
else
falldmg(dmg,false,false)
end
end
end
end)
The issue is whenever a player gets ragdolled they are able to bypass fall damage.
This is the code for my ragdoll (which is run on the client)
RS.Handlers.RagdollHandler.OnClientEvent:Connect(function(ragdoll)
local char = plrs.LocalPlayer.Character
local hum = char:WaitForChild("Humanoid")
if ragdoll then
hum:SetStateEnabled(Enum.HumanoidStateType.GettingUp,false)
hum.PlatformStand = true
hum:ChangeState(Enum.HumanoidStateType.Ragdoll)
else
hum:SetStateEnabled(Enum.HumanoidStateType.GettingUp,true)
hum.PlatformStand = false
hum:ChangeState(Enum.HumanoidStateType.GettingUp)
end
end)
what is the best way to make sure people dont get fall damage immunity if they are ragdolled?
I assume the FreeFalling state doesn’t get fired since PlatformStand (or Ragdoll) might not allow that state to be called.
The way I would approach solving this is to output every state change (use Humanoid.StateChanged for this) and see what states are getting outputted when you do your ragdoll. The hope is there is some state that fires when you land while ragdolling. If not, you might have to do a more manual approach (when a velocity changes from -y to 0 or +y, do damage depending on the difference.)
the ragdoll humanoid state blocks freefalling state from taking over.
I will have to take a manual approach I suppose.
How would I detect when the player is falling and when the player has landed?
Hello! One idea could be to check the velocity of the HumanoidRootPart. To do this I would listen to the velocity and if it is greater than a pre-determined value then this means they are falling. I would then check for a sudden change in velocity, meaning they have collided with something.
If you only wanted this to work when falling down from a height I would just check the velocity in the Y-axis.
how would I “listen” to the velocity exactly? I feel like using a loop wouldn’t be too performance-friendly and using getpropertychangedsignal doesn’t seem to trigger for some reason.
So it says the best thing to do is to either check the velocity with RunService.Stepped or use a while loop with task.wait() inside. I don’t think it would be too performance heavy but you could test to see if it is for sure!