So i'm trying to make a tree vanish after it's been hit 5 times. That bit works.
However, after it goes invisible; and then becomes visible again, the loop doesn't continue. As in, when it gets to 5 again, it does nothing...
Any ideas?
while script.Parent.Damage.Value <5 do
wait()
end
if script.Parent.Damage.Value >= 5 then
script.Parent.Name = "Gone"
local descendants = script.Parent:GetDescendants()
for index, descendant in pairs(descendants) do
if descendant:IsA("BasePart") then
descendant.Transparency = 1
descendant.CanCollide = false
end
end
wait(10)
local descendants2 = script.Parent:GetDescendants()
for index, boo in pairs(descendants2) do
if boo:IsA("BasePart") then
boo.Transparency = 0
boo.CanCollide = true
end
end
script.Parent.Name = "Tree"
script.Parent.Damage.Value = 0
end
Thank you.

1 comment
You should be using events not loops for this work