Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

How to make fall damage script?

Asked by
igric 29
10 years ago

I make place where need fall damage How to make that script?

2
This isn't a Q&A site. Please search through Free Models. Shawnyg 4330 — 10y
0
Free Models don't work i need make script igric 29 — 10y

1 answer

Log in to vote
0
Answered by 10 years ago

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!

Ad

Answer this question