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.
db=false
function heal(player)
if db then return end
db=true
local h = player.Parent:FindFirstChild("Humanoid")
if h~= nil and h:FindFirstChild("Value")== nil then
local brick=script.Parent
character=h.Parent
torso=h.Parent.Torso
tp=torso.Position
bp=brick.Position
if h.Health <100 then
print("Charging Heal-Pad!")
for i=1,10 do
wait(.1)
brick.Transparency=brick.Transparency + .1
end
brick.BrickColor=BrickColor.new("Really red")
wait(.1)
for j=1,10 do
wait(.1)
brick.Transparency=brick.Transparency - .1
end
while h.Health < 100 and (tp-bp).Magnitude<=5.6 do ----------------------this line------------------------
wait(.111111)
h.Health=h.Health+4
end
print("All Healed! Step off to re")
x=Instance.new("StringValue")
x.Parent=h
while true do
wait(.5)
if torso:FindFirstChild("Value") ~= nil then break end
if (tp-bp).Magnitude>=5.6 then
for _=1,10 do
wait(.1)
brick.Transparency=brick.Transparency + .1
end
brick.BrickColor=BrickColor.new("Black")
for s_=1,10 do
wait(.1)
brick.Transparency=brick.Transparency - .1
NOOBMONSTER=Instance.new("StringValue")
NOOBMONSTER.Parent=torso
end
end
end
es=torso:GetChildren()
for ess=1,#es do
if es[ess].Name==("Value") then es[ess]:Destroy() end
end
x.Parent=nil
db=false return end
end
db=false
end
script.Parent.Touched:connect(heal)
