Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to I detect a part's parent?

Asked by 7 years ago

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
0
So what is wrong with the above script? Is "script.Parent.Parent == game.Workspace" no returning true? dragonkeeper467 453 — 7y
0
The script produces an error message on line 3 only when its true... I have no idea why. MisterMCCreeper -4 — 7y
0
Please post the entire script, since the simplified version appears to have no trouble? (Also, please, use Destroy instead) lucas200206 90 — 7y
0
Nvm, made it work by reloading the map MisterMCCreeper -4 — 7y
View all comments (2 more)
0
:Remove() has been deprecated. Shawnyg 4330 — 7y
0
Really? Because it still works... MisterMCCreeper -4 — 7y

Answer this question