I've ran into an annoying issue with my Countdown GUI. The script is supposed to count down how many seconds until a new minigame is chosen. However, the script stops working after it waits for 3 seconds. I did not run into this issue before I moved the script to a new place instance.
local MainBar = game.StarterGui:FindFirstChild("MainBar")
---------------
local MainBarFrame = MainBar:FindFirstChild("MainBarFrame")
---------------
local MainBarText = MainBarFrame:FindFirstChild("MainBarText")
---------------
local Minigames = game.ReplicatedStorage.Minigames:GetChildren()
---------------------------------------
MainBarText.Text = "Get ready for the next minigame!"
wait(3)
for i = 15,0,-1 do --How much time is left until the next minigame
MainBarText.Text = "Next minigame in " .. i .. " seconds!"
wait(1)
if i == 0 then
MainBarText.Text = "Choosing a minigame..."
Minigame = Minigames[math.random(1,#Minigames)]:Clone()
Minigame.Parent = game.workspace
MainBarText.Text = "Minigame: " .. Minigame.MinigameName.Value .. " by " .. Minigame.MinigameCreator.Value .. ""
This is what the Output told me:
16:40:55.368 - MainBar is not a valid member of PlayerGui 16:40:55.369 - Script 'Players.Player.PlayerGui.GameScript', Line 7 16:40:55.369 - Stack End

2 comments
Well, you're supposed to set MainBar to the Player's GUI. Although, by the error, it somehow seems you have. Is your game FIlteringEnabled?
There is no need for the 'if i == 0 then' if statement inside the for loop. Put it outside the for loop without the if statement. It will run right when the for loop finishes.