I've been building a game in which the player has to shoot an object through a device. The object in question gets cloned from a folder into the physical workspace. However, it can't execute code based on what its parent is, a vital part of the script.

I've simplified the script and put it below. Can you help me?

while true do
	wait()
	if script.Parent.Parent == game.Workspace  then
		script:Remove()
	end
end

6 comments

0

So what is wrong with the above script? Is "script.Parent.Parent == game.Workspace" no returning true?

0

The script produces an error message on line 3 only when its true... I have no idea why.

0

Please post the entire script, since the simplified version appears to have no trouble? (Also, please, use Destroy instead)

0

Nvm, made it work by reloading the map

0

:Remove() has been deprecated.

0

Really? Because it still works...