I make place where need fall damage How to make that script?
✓ ANSWER ACCEPTED
How to make fall damage script?
1 answer
✓ Accepted answer
You need to check the player's falling speed with the "WalkSpeed" field of the player, then from there you increase by 1 a field called fallDamage, from that you can remove health in base the fallDamage, let's do it! CREATE A LOCALSCRIPT!
local fallDamage = 0 -- We define the amount of the damage when a player falls
function takeDamageFromFall(part)
-- If your falling speed is higher than 30 (the player's default one is 16)
if player.WalkSpeed > 30 then
-- While falling the walkspeed will be increased by 1 each tick (20 milliseconds)
while player.WalkSpeed == player.WalkSpeed + 1 do
-- As the walkspeed increases, the fallDamage increases too by 1
fallDamage = fallDamage + 1
end
end
end
-- If the player touched something in the Workspace
for _, part in pairs(game.Workspace:GetChildren()) do
-- We will remove the amount of health as same as the fallDamage's one by dividing it by 2
part.Touched:Connect(takeDamageFromFall)
game.Players.LocalPlayer.Health = game.Players.LocalPlayer.Health - (fallDamage / 2)
end
I did it while I was hurrying. Tell me if it doesn't work, when I arrive I'll take cares about the problems and resolve it. Ps: you can change the dividing amount if you take less/more damage than what you thought!
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
This isn't a Q&A site. Please search through Free Models.
Free Models don't work i need make script