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

This won't :Destroy() ? (Fixed)

Issue that I had - Thing wouldn't destroy, this was the problem code -

local rounddeciders2 = game.Lighting.rounddeciders

local rounddeciders = game.Workspace.rounddeciders

while true do
	
wait(2)

rounddeciders:Destroy()

print('round begin')

wait(2)

rounddeciders2:Clone().Parent = game.Workspace
print('round over')

end

I had to get rid of the first two variables, which meant it looked like this -

while true do
	
wait(2)

game.Workspace.rounddeciders:Destroy()

print('round begin')

wait(2)

game.Lighting.rounddeciders:Clone().Parent = game.Workspace

print('round over')

end

Thanks for helping, ioutragous.

2 answers

✓ Accepted answer

Your script works only once because, once the rounddeciders you give the script gets destroyed, and it never refreshes to the new one because it tries to Destroy() the first rounddeciders you showed it.

Solution: Move line 3 to line 6, or just anywhere in front of while true do and behind rounddeciders:Destroy()

local rounddeciders2 = game.ServerStorage.rounddeciders --There's ServerStorage for your thing, use it.

while true do
local rounddeciders = workspace.rounddeciders --You can refer to game.Workspace as workspace
wait(2)

rounddeciders:Destroy()

print('round begin')

wait(2)

rounddeciders2:Clone().Parent = workspace
print('round over')

end

P.S. Guess ioutrageous fixed your script out of SH. His solution is of course correct. You don't need to get rid of the variables if you don't want to, however - just remember the variables only update when you call them. You only call rounddeciders and rounddeciders2 once, so they always refer to the item which exists at first - that is why the script did not Destroy().

Instead of :Destroy() try using :remove() Hope this help! :D if it still doesn't work please leave a comment!

2 comments

0

Doesn't work, sorry. Thanks for helping though!

0

If Destroy() doesn't work, Remove() won't do either. Their difference is that Remove() sets the instance's parent to nil, making them able to be brought back and Destroy() basically shreds them. Never use Remove() in place of Destroy() when you can use Destroy() for more latter performance.

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