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

What is wrong with this script used to remove its parent?

Asked by 10 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

I made a LocalScript which is suppose to destroy/remove its Parent which is a Model. This is the script I made:

function DestroyName() --name of function
    script.Parent:destroy() --this is suppose to destroy it
end --end
while true do --order to Begin
    DestroyName() --what to do
end --end

This didn't work! It didn't destroy/remove its Parent. Can someone help with this?

0
Why not use Debris? : game.Debris:AddItem( Obj, Delay ) hiccup111 231 — 10y
0
Because I don't know what is debris,what it does, and what its used for... vectorxray 5 — 10y

2 answers

Log in to vote
0
Answered by 10 years ago

Try this there is no guarantee though... If it did work a upvote is appreciated, thanks.

function DestroyName() --name of function
    script.Parent:Destroy() --this is suppose to destroy it
end --end
while wait(0.1) do--order to Begin
    DestroyName() --what to do
end --end
0
@Perci1 Why would people repost basically the exact same thing besides a question in there answer. .. You could have just easily commented on mine instead of reposting. GetSporked 5 — 10y
1
I attempted to help by explaining the logic, instead of just posting code that still did not cover everything. Perci1 4988 — 10y
0
Ok then GetSporked 5 — 10y
0
Thank you this works! also thanks to Perci1 for the logic I appreciate it! vectorxray 5 — 10y
Ad
Log in to vote
1
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
10 years ago

Well, destroy should be capital (So, Destroy())

Second, while loops without a wait() will crash the game.

Third, what is the point of a while loop? Once it's destroyed, you should not need to destroy it again.

Fourth, a local script should not be necessary.

0
When did I say I wanted to make a loop? vectorxray 5 — 10y
0
'while true do DestroyName() end' This is a while loop, but it should not be necessary. Perci1 4988 — 10y

Answer this question