|
| 27 Jun 2014 12:43 AM |
This script is supposed to take away health if a player is in the terrain water but when the player is not in the water anymore, it still takes away health. Why won't this script work properly?
game.Players.PlayerAdded:connect(function(Player) Player.CharacterAdded:connect(function(char) local humanoid = char:WaitForChild("Humanoid") local drown = false
humanoid.Swimming:connect(function(swim) if swim then drown = true elseif not swim then drown = false end end)
while wait(1) do if drown then humanoid:TakeDamage(5) end end
end) end) |
|
|
| Report Abuse |
|
|
|
| 27 Jun 2014 12:50 AM |
I'm not entirely sure however try changing "if then humanoid:TakeDamage(5)" to if drown == true |
|
|
| Report Abuse |
|
|
|
| 27 Jun 2014 01:37 AM |
| if drown and if drown == true are basically the same. Anyone know the problem? |
|
|
| Report Abuse |
|
|
|
| 27 Jun 2014 01:45 AM |
humanoid.Swimming:connect(function(swim) while wait(1) do if swim then drown = true if drown then humanoid:TakeDamage(5) elseif not swim then drown = false ???
|
|
|
| Report Abuse |
|
|
|
| 27 Jun 2014 05:05 AM |
| Still won't work, anyone know why? |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
| 28 Jun 2014 01:23 AM |
Try this: game.Players.PlayerAdded:connect(function(Player) Player.CharacterAdded:connect(function(char) local humanoid = char:WaitForChild("Humanoid") local drown = false
humanoid.Swimming:connect(function(swim) if swim > 0 then drown = true elseif swim < 1 then drown = false end end)
while wait(1) do if drown then humanoid:TakeDamage(5) end end
end) end) |
|
|
| Report Abuse |
|
|
|
| 28 Jun 2014 02:09 AM |
| It worked! :D But can I also make it take away health even if the player is in the terrain water at idle(No speed)? |
|
|
| Report Abuse |
|
|
|
| 28 Jun 2014 02:14 AM |
| Have you tried using the Touched event?. |
|
|
| Report Abuse |
|
|
|
| 28 Jun 2014 02:27 AM |
| I don't think that the Touched event would work for the water terrain and Roblox Lua has the Swimming event to deal with the terrain water. So, is it possible to make the script work even when the player is at idle or floating on the water (The speed will be 0) ? |
|
|
| Report Abuse |
|
|
|
| 28 Jun 2014 02:43 AM |
| Not a solution I can think of at the moment, have you tried increasing the amount of damage done to perhaps something such as 10 to prevent them from just standing still to heal and escape?. |
|
|
| Report Abuse |
|
|
|
| 28 Jun 2014 03:08 AM |
| Yeah, I have, it did work well :L . I need the script to also deal damage while the player is at idle in the water. Anyone know? |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
| |
|
|
| 28 Jun 2014 08:06 AM |
what logic is this? so when you swim you're automatically drowning?? |
|
|
| Report Abuse |
|
|
|
| 28 Jun 2014 08:25 AM |
| Oh, no, just when you are in the water, but this script doesn't work properly. Anyone know why? |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|