So an issue im currently having with my script is that when you remove everything past the wait(5) all the plates disappear at once like it should but when you add everything after the script breaks and only one of the plates disappears. Why is this and how can I fix this?
-- Plate Variables local redplate = script.Parent.Plate.Red local blueplate = script.Parent.Plate.Blue local greenplate = script.Parent.Plate.Green local yellowplate = script.Parent.Plate.Yellow local platemodel = script.Parent.Plate local platetable = {blueplate, greenplate, yellowplate, redplate} --Simon Variables local redsimon = script.Parent.Simon.Red1 local bluesimon = script.Parent.Simon.Blue1 local yellowsimon = script.Parent.Simon.Yellow1 local greensimon = script.Parent.Simon.Green1 --Main Script while true do wait(10) r = platetable[math.random(#platetable)] r.Parent = script.Parent.PlateStorage for i, v in pairs(platemodel:GetDescendants()) do if v:IsA("BasePart") then v.Transparency = 1 v.CanCollide = false wait(5) v.Transparency = 0 v.CanCollide = true end end end
I figured this out on my own, the issue was that I put the wait statement in the loop instead of outside it. Heres the updated code.
while true do wait(7) r = platetable[math.random(#platetable)] r.Parent = script.Parent.PlateStorage _G.SimonActivate = true wait(3) for i, v in pairs(platemodel:GetDescendants()) do if v:IsA("BasePart") then v.Transparency = 1 v.CanCollide = false end end wait(5) for i, v in pairs(platemodel:GetDescendants()) do if v:IsA("BasePart") then v.Transparency = 0 v.CanCollide = true r.Parent = script.Parent.Plate end end end