I’m confused, I set the height length to 80 so anything below that isn’t counted as fall damage. This works, but the velocity for the player’s humanoidrootpart was -84, and I want to scale the damage with how low the fall is. How can I do this?
You could use HumanoidStateTypes here, when the HumanoidState is changed to Enum.HumanoidStateType.FallingDown
you could store the current position.
When the Humanoid’s state is changed from FallingDown
to any other state later on, you could get the position again, now u would calculate the Magnitude
of the 2 vectors, i.e, (StartPosition - EndPosition).Magnitude
that would give you the distance in studs that player fell. You can then damage based on that.
Another way this could be done:
local Start_Acc = 80 -- Minimum player velocity for them to take damage
local Damage_Per = 1 -- Amount of damage done per value for velocity
local Humanoid = game:GetService("Players").LocalPlayer.Character.Humanoid
local InAir = false
Humanoid:GetPropertyChangedSignal("FloorMaterial"):connect(function()
if Humanoid.FloorMaterial == Enum.Material.Air and not InAir then
InAir = true
elseif InAir then
InAir = false
if -Humanoid.RootPart.Velocity.Y > Start_Acc then
Humanoid:TakeDamage((-Humanoid.RootPart.Velocity.Y - Start_Acc) * Damage_Per)
end
end
end)