Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why isn't this script not deleting the parent, am I ment to add a loop?

This is for when the generator dies the parent is destroyed

if script.Parent.Generator.Health <= 0
then
	script.Parent:Destroy()
end

1 comment

0

Yes add a while loop

1 answer

✓ Accepted answer

This is because it only runs once, when the server first boots up. You should do:

while true do
	if script.Parent.Generator.Health <= 0 then
		script.Parent:Destroy()
	end
	wait()
end

edit: if someone sees this, the comment's reply is actually the more "correct" answer. try

script.Parent.Generator:GetPropertyChangedSignal("Health"):Connect(function()
	if script.Parent.Generator.Health <= 0 then
		script.Parent:Destroy()
	end
end)

this will run more efficiently

3 comments

0

thx ill try it

0

Or script.Parent.Generator.Health:GetPropertyChangedSignal("Helath"):Connect(function() because then you don't need the loop

0

Thx it worked

This discussion is preserved as it was. New answers, comments, and votes are closed.