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

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

Asked by
pwnd64 106
9 years ago

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

Log in to vote
0
Answered by
Marios2 360 Moderation Voter
9 years ago

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().

Ad
Log in to vote
0
Answered by 9 years ago

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

0
Doesn't work, sorry. Thanks for helping though! pwnd64 106 — 9y
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. Marios2 360 — 9y

Answer this question