Hello! i was wondering how would i make it so a script can detect when a a player falls a certain amount of studs Mid-Air?
This is the script i use:
local char = script.Parent
local root = char:WaitForChild(“HumanoidRootPart”)
local humanoid = char:WaitForChild(“Humanoid”)
if humanoid and root then
local headHeight
humanoid.FreeFalling:Connect(function (state)
if state then
headHeight = root.Position.Y
elseif not state and headHeight ~= nil then
pcall(function ()
local fell = headHeight - root.Position.Y
if fell >= 40 then
script.Parent.Ragdolled.Value=true
end
end)
end
end)
end
But this script only detects it when the player hits the ground, any solutions?
Humanoid.StateChanged:Connect(function(PreviousState, NewState)
if NewState == Enum.HumanoidStateType.Freefall then
-- what to do when it starts falling
elseif NewState == Enum.HumanoidStateType.Landed then
-- what to do when it landed
end
end
Or just when they start falling get their position store it in a variable wait a second then get their position again and if it’s how ever many studs different in the Y axis then you can enable your damage
Roblox gravity by default I believe is 196 studs/s
Basically
H = Height (what you want)
G = Gravity (9.8)
T = Time from falling to landed