So my script puts a block into ReplicatedStorage to get rid of it for a couple of seconds. Put it takes about 2 seconds for it to actually disappear.
Code:
local AllColoursFolder = game.Workspace.Colours:GetChildren()
local function StartRound()
wait()
local randomColour = game.Workspace.Colours:GetChildren()[math.random(1, 2)]
print (randomColour)
changeColour(randomColour)
Countdown()
for i,v in pairs (game.Workspace.Colours:GetChildren()) do
v.Parent = game.ReplicatedStorage
randomColour.Parent = workspace.Colours
wait(3)
v.Parent = workspace.Colours
end
end
Edit: It was meant to disappear on go and it also only happens sometimes…
This happens because you have a for loop that waits. So every time it switches to a different part, it waits 3 seconds and parents the old part then moves to the new part.
Instead, you could make two different for loops and seperate them with a wait.
@ScarletHypernova’s solution is probably the best one for this problem
Here’s an example code so that you can understand it better:
local AllColoursFolder = game.Workspace.Colours:GetChildren()
local function StartRound()
wait()
local randomColour = game.Workspace.Colours:GetChildren()[math.random(1, 2)]
print (randomColour)
changeColour(randomColour)
Countdown()
local colours = game.Workspace.Colours:GetChildren() --or use AllColoursFolder defined above, as long as no children are changed beforehand
for i,v in pairs (colours) do
v.Parent = game.ReplicatedStorage
randomColour.Parent = workspace.Colours --not sure why this one is in the loop so I'm leaving it here
end
wait(3)
for i,v in pairs (colours) do --use the same "colours" variable to make sure only the same children are put back
v.Parent = workspace.Colours
end
end