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

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

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?

2 comments

0

Why not use Debris? : game.Debris:AddItem( Obj, Delay )

0

Because I don't know what is debris,what it does, and what its used for...

2 answers

✓ Accepted answer

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

4 comments

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.

1

I attempted to help by explaining the logic, instead of just posting code that still did not cover everything.

0

Ok then

0

Thank you this works! also thanks to Perci1 for the logic I appreciate it!

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.

2 comments

0

When did I say I wanted to make a loop?

0

'while true do DestroyName() end' This is a while loop, but it should not be necessary.

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