Hey!
I’m trying To Get to Know For How much Time the Player Stays in the Air For.
Suppose the Player Jumps, For Some time He is in the “Falling” State Type. Is there A Way i Can Calculate for How Long the Player is Falling In the Air? (Or in the Air)
Basically Calculate the Time in Which the Player is In the Falling State Type aka Falling From a Height
I commented about this in the past.
Maybe you are making a fall damage system, this is how you would do it if not, well this should also solve that issue.
This would be used if you want to enable fall damage for a certain height: h=1/2gt^2 (this calculates height)
H = Height (what you want)
G = Gravity (9.8)
T = Time from falling to landed
For time it should look like
V is your velocity you can just get from the player or calculate from the height but that seems a bit redundant.
T = V/G
Definitely look at this link, the post above mine is what you can use to detect if the player is falling or not.
local StartTime
Humanoid.StateChanged:Connect(function(_, State)
if State == Enum.HumanoidStateType.Freefall then
StartTime = tick()
elseif State == Enum.HumanoidStateType.Landed then
local AirTime = tick() - StartTime
print("Was in air for "..AirTime.."s")
end
end))
It would be something like this, havent tested it. I am currently on mobile. Tomorrow I will edit it when on PC and provide an explanation / breakdown of how it works.