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

Why isn't this remove script not working, --this is to make the title longer--?

This sctipt is for when the generator dies then it is removed

z = script.Parent

backup = z:clone()
z.Touched:Connect(function(hit)
	while true do
		wait(5)
		if z.Generator.Health == 0 then
		z:Remove()
		
	end
	if z == nil then
		wait(4)
		z:Remove()
	end
end 

2 comments

0

replace Remove() with Destroy(), remove is deprecated, this will cause severe lag because over 1000 threads will be created if the player steps on the z part. Also your z.Generator.Health might be localized, keep that in mind..

0

thx

1 answer

Hello, FluffySheep46209!

It was missing a end on your script

z = script.Parent

backup = z:clone()
z.Touched:Connect(function(hit)
    while true do
        wait(5)
        if z.Generator.Health == 0 then
            z:Remove()
       end
       if z == nil then
           wait(4)
           z:Remove()
      end
    end --missing end
end) --bracket missing

If this solves your issue, please accept the answer

4 comments

0

It still dosen't work

1

any errors on console?

0

what's the error you get?

1

Are you ever setting z.Generator.Health to 0?

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