There's a bug in this script, the bug is if someone is healing, and they get killed, the script will break. It's a button, where if you step on it, it will turn black, heal you, then turn back to red. When someone kills you while you're healing it'll turn black, but then it will not go back to red, and the script breaks so you can not heal with it anymore. Can somebody help me out with this bug? Here's the script:
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
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 black")
wait(.1)
for j=1,10 do
wait(.1)
brick.Transparency=brick.Transparency - .1
end
while h.Health < 100 do
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
tp=torso.Position
bp=brick.Position
if (tp-bp).Magnitude>=5.6 then
for _=1,10 do
wait(.1)
brick.Transparency=brick.Transparency + .1
end
brick.BrickColor=BrickColor.new("Really red")
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)

1 comment
Wow so long