I will explain how to calculate the fall damage thanks to the height of the fall :
- Get Y of the player with
- When the player fall define his height !
- When the player land define his height !
- Check if the player land in the water, if the player land in water and the height is <100 kill the player else apply the damage by subtracting the height of when you fall from that of when you land .
I now show you the script placed in StarterCharacterScripts :
local RunService = game:GetService("RunService") local Character = game.Players.LocalPlayer.Character local Humanoid = Character:FindFirstChildOfClass("Humanoid") local YF local YL Humanoid.StateChanged:Connect(function(OldState, NewState) if NewState == Enum.HumanoidStateType.Freefall then YF = Character:GetPrimaryPartCFrame().Position.Y elseif NewState == Enum.HumanoidStateType.Landed then YL = Character:GetPrimaryPartCFrame().Position.Y if YF - YL > 25 then Humanoid:TakeDamage(YF - YL) end elseif OldState == Enum.HumanoidStateType.Freefall and NewState == Enum.HumanoidStateType.Swimming then YL = Character:GetPrimaryPartCFrame().Position.Y if YF - YL > 100 then Humanoid:TakeDamage(Humanoid.MaxHealth) end end end)
Now I let you send me your positive/negative feedback :
- This topic is well explained !
- This topic is poorly explained !
- This topic was useful to you !
- This topic wasn’t useful to you !
Have a good day !