Nesting While loops?
Greetings fellow Robloxians... I've been writing this script that does as follows:
(Player stands on brick the brick changes color if the players health isn't 100 it heals him and once he leaves the pad it changes back to the original color... )
(THE PROBLEM- The problem I'm having is that on the marked line bellow I can't figure out how to have the player heal only while he is standing on the pad.. If he moves he no longer receives healing. I tried to nest the while loop but had no luck. I've did some researching and articles say you nest while loops by:
while(condition)
do
while(condition)
do
statement(s)
end
statement(s)
end
However I had no luck with that so I tried to use the 'and' identifier and once more I had no luck. I'd appreciate if a trained eye can view my code and tell me what I'm doing wrong, thank you very much in advance.
008 | local h = player.Parent:FindFirstChild( "Humanoid" ) |
010 | if h~ = nil and h:FindFirstChild( "Value" ) = = nil then |
012 | local brick = script.Parent |
024 | print ( "Charging Heal-Pad!" ) |
031 | brick.Transparency = brick.Transparency + . 1 |
039 | brick.BrickColor = BrickColor.new( "Really red" ) |
046 | brick.Transparency = brick.Transparency - . 1 |
052 | while h.Health < 100 and (tp-bp).Magnitude< = 5.6 do |
061 | print ( "All Healed! Step off to re" ) |
063 | x = Instance.new( "StringValue" ) |
072 | if torso:FindFirstChild( "Value" ) ~ = nil then break end |
074 | if (tp-bp).Magnitude> = 5.6 then |
082 | brick.Transparency = brick.Transparency + . 1 |
087 | brick.BrickColor = BrickColor.new( "Black" ) |
094 | brick.Transparency = brick.Transparency - . 1 |
096 | NOOBMONSTER = Instance.new( "StringValue" ) |
097 | NOOBMONSTER.Parent = torso |
106 | es = torso:GetChildren() |
110 | if es [ ess ] .Name = = ( "Value" ) then es [ ess ] :Destroy() end |
133 | script.Parent.Touched:connect(heal) |