Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Put in ServerScriptService
- local damageHeight = 14 -- The height at which the player will start getting damaged at
- local lethalHeight = 26 -- The height at which the player will get killed
- game:GetService("Players").PlayerAdded:Connect(function (plr)
- plr.CharacterAdded:Connect(function (char)
- local root = char:WaitForChild("HumanoidRootPart")
- local humanoid = char:WaitForChild("Humanoid")
- if humanoid and root then
- local headHeight
- wait(3) -- Prevent the player from dying on spawn
- 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 >= lethalHeight then
- humanoid.Health = 0
- elseif fell >= damageHeight then
- humanoid.Health = humanoid.Health - math.floor(fell)
- end
- end)
- end
- end)
- end
- end)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement