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

Why does my fall damage script kill you when the character is in a negative Y value?

Asked by 8 years ago

I know I'm bad at phrasing titles, but my point is that whenever the character is in a Y-axis of (0,-1,0) and below, it just automatically dies. I do not know at all why! Also, in some general cases, the character just dies for unkown reasons because of fall damage. If you can help me improve this script or create an entirely new one, it would be a great help. (This was taken from free models and edited from me so I could learn)

01wait(5)
02 
03bin = script.Parent
04probability = math.random(-2, 10)
05humanoid = bin:FindFirstChild("Humanoid")
06ll = bin:FindFirstChild("Left Leg")
07rl = bin:FindFirstChild("Right Leg")
08la = bin:FindFirstChild("Left Arm")
09ra = bin:FindFirstChild("Right Arm")
10h = bin:FindFirstChild("Head")
11freefall = false
12startingHeight = 0
13endingHeight = 0
14ll.Elasticity = 0
15rl.Elasticity = 0
View all 48 lines...

1 answer

Log in to vote
0
Answered by 8 years ago
Edited 8 years ago

Try using this in a script in ServerStorage. If that does not work, tell me the errors.

Don't forget to accept this answer if it helped!

EDIT: I made a mistake. I put :GetAllChildren() instead of :GetChildren()

R6:

01wait(1)
02local MaxVelocity = 15
03local DMGperVelocity = 3
04game.Players.PlayerAdded:connect(function(plr)
05    local FreeFall = false
06    plr.Character.Humanoid.FreeFalling:connect(function()
07        FreeFall = true
08    end)
09    plr.Character:GetChildren().Touched:connect(function()
10        if plr.Character.Velocity >= MaxVelocity then
11            plr.Character.Humanoid.Health =  plr.Character.Humanoid.Health - (plr.Character.Torso.Velocity * DMGperVelocity)
12        end
13    end)
14end)

R15:

01wait(1)
02local MaxVelocity = 15
03local DMGperVelocity = 3
04game.Players.PlayerAdded:connect(function(plr)
05    local FreeFall = false
06    plr.Character.Humanoid.FreeFalling:connect(function()
07        FreeFall = true
08    end)
09    plr.Character:GetChildren().Touched:connect(function()
10        if plr.Character.Velocity >= MaxVelocity then
11            plr.Character.Humanoid.Health =  plr.Character.Humanoid.Health - (plr.Character.UpperTorso.Velocity * DMGperVelocity)
12        end
13    end)
14end)
0
man. I already know this doesnt work. You use GetAllChildren(). laughablehaha 494 — 8y
Ad

Answer this question