How would I go on making a 'fall' damage?

The title is self-explanatory. I would like to know how I can achieve this system. Specifically, I want my ‘fall’ damage system to follow this way:

  1. Player jumps
  2. Damage the player according to the difference from the max position and the ‘ground’ position
  3. Slow down the player’s walk speed by X amount, depending on how many studs they felt
Example

The player has jumped from the starting position 0, 0, 0. The max position he achieved with the jump was 0, 30, 0 (30 studs upwards). Then, he landed on the ground’s position 0, -10, 0 (10 studs downwards). The minimum height to receive damage is, for instance, 10 studs, and the damage increases linearly from this starting point. We can assume 100 studs equals 100% of the player’s life; therefore, they would take damage of approximately 50% of their max health.

All I want to know is ideas from you all; don’t send the full code, I just want you all to share thoughts on how to do this system. Additionally, it may be more precise to calculate the player’s max velocity, since the player can fall from 100 studs upwards but move at a constant, slow speed. Any help is really appreciated, thanks!

1 Like

Sorry this is my first post but ill try to help and explain the best that I can. Would you like to know the max height of the player before they start falling. You could try to using humanoid state changed to monitor if and when the player is falling (Enum.HumanoidStateType.FreeFall). When free fall actives you could start a heart beat or while loop that slowly decreases the walk speed of the player while the state is true. You can also get when they have landed (Enum.HumanoidStateType.Landed). When this state starts you could stop the walk speed connection and then apply the fall damage. Could be helpful i don’t know if there are better ways.

This document provides a quite helpful example:
landedhttps://create.roblox.com/docs/reference/engine/classes/Humanoid#StateChanged

5 Likes

Could you elaborate? What you mean by decreasing player’s walkpeed

EDIT: nvm I think I understand what you meant

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.