How do I keep a number above negative?
Whenenver I'm in the part the air value will go above 100 and sometimes at -1 or -2. Also when the value is at 0 the player will not get hurt. What needs to be fixed?
01 | Underwater = script.Parent |
02 | Underwater.Touched:Connect( function (hit) |
03 | if hit.Parent.ClassName = = 'Model' and hit.Parent:FindFirstChild( 'Humanoid' ) and not hit.Parent:FindFirstChild( 'KillerTag' ) then |
04 | print ( "Head in water" ) |
05 | local character = hit.Parent |
06 | Air = character:FindFirstChild( "Air" ) |
07 | local Humanoid = character:FindFirstChild( "Humanoid" ) |
08 | if hit.Name = = "Head" then |
09 | while Air.Value > - 1 do |
11 | Air.Value = Air.Value - 1 |
12 | while Air.Value < = 0 do |
13 | Humanoid.Health = Humanoid.Health - 10 |
20 | Underwater.TouchEnded:Connect( function (hit) |
21 | if hit.Parent.ClassName = = 'Model' and hit.Parent:FindFirstChild( 'Humanoid' ) and not hit.Parent:FindFirstChild( 'KillerTag' ) then |
22 | local character = hit.Parent |
23 | Air = character:FindFirstChild( "Air" ) |
24 | local Humanoid = character:FindFirstChild( "Humanoid" ) |
25 | while Air.Value < 101 do |
27 | Air.Value = Air.Value + 1 |