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

Script continues to run after Destroy()?

I'm really confused. I simply wanted a script to destroy its parent (and itself), that's all. You can find the rest of my code here.

You can easily notice this part (I added parent here):

if not closeEnough then
	script.Parent:Destroy()
end

The problem is, it says that parent is nil. So I did this:

if not closeEnough then
	if script.Parent then script.Parent:Destroy() else script:Destroy() end
end

The results were slightly strange, so I added an error function:

if not closeEnough then
	if script.Parent then script.Parent:Destroy() else script:Destroy() end
	error("my life is a lie")
end

And guess what.

my life is a lie

1 answer

✓ Accepted answer

ROBLOX is weird.

You can use return. Example:

do
	return
end
print(1) -- wont print

2 comments

0

I can return even if it's not inside a function?

1

do return end print('a') :P

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