I made a fall damage script and it works but when I die and respawn the script does not damage me anymore.
script:
local min = 9
local max = 49
local w
local fall
game.Players.PlayerAdded:Connect(function(player)
wait(2)
local char = player.Character
local hum = char.Humanoid
local humrootpart = char.HumanoidRootPart
print(humrootpart.Position.Y)
hum.StateChanged:Connect(function(old, new)
if new == Enum.HumanoidStateType.Freefall then
w = humrootpart.Position.Y
elseif (new == Enum.HumanoidStateType.Landed and old == Enum.HumanoidStateType.Freefall) or (new == Enum.HumanoidStateType.Running and old == Enum.HumanoidStateType.Freefall) then
fall = w - humrootpart.Position.Y
print(fall)
if fall >= max then
hum.Health = 0
elseif fall >= min then
hum.Health -= math.floor(fall)
end
end
end)
end)