Why does my fall damage script kill you when the character is in a negative Y value?
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)
04 | probability = math.random(- 2 , 10 ) |
05 | humanoid = bin:FindFirstChild( "Humanoid" ) |
06 | ll = bin:FindFirstChild( "Left Leg" ) |
07 | rl = bin:FindFirstChild( "Right Leg" ) |
08 | la = bin:FindFirstChild( "Left Arm" ) |
09 | ra = bin:FindFirstChild( "Right Arm" ) |
10 | h = bin:FindFirstChild( "Head" ) |
19 | bin.Torso.Elasticity = 0 |
24 | startingHeight = bin.Torso.Position.y |
27 | function onTouched(part) |
28 | if freefall = = true and bin:findFirstChild( "Parachute" ) = = nil and humanoid.Health > 0 and part.CanCollide = = true then |
30 | endingHeight = bin.Torso.Position.y |
31 | local averageHeight = startingHeight - endingHeight |
32 | if averageHeight > 25 then |
33 | if bin:FindFirstChild( "Torso" ) and bin.Torso:FindFirstChild( "Crunch" ) then |
34 | bin.Torso.Crunch:Play() |
36 | humanoid.Health = humanoid.Health - ((averageHeight * 0.1 )^ 2 ) |
43 | humanoid.FreeFalling:connect(onFreeFall) |
44 | ll.Touched:connect(onTouched) |
45 | rl.Touched:connect(onTouched) |
46 | la.Touched:connect(onTouched) |
47 | ra.Touched:connect(onTouched) |
48 | h.Touched:connect(onTouched) |