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

My intermission isn't running?

I'm trying to run an intermission if there are >= 2 players in the game. I have this code, but it's giving no errors, and it looks perfectly fine in my opinion. Here is the code.

local ControlBoard = workspace:WaitForChild("ControlBoard").Holder.Mode
local Sword = game.ReplicatedStorage:WaitForChild("Sword")
local Maps = game.ReplicatedStorage:WaitForChild("Maps")
local IntermissionTime = 10
local RequiredPlayers = 2
local GameRunning = false
local GameTime = 60

local function Game()
	if GameRunning == false then
		GameRunning = true
		local function RunIntermission()
			for i = IntermissionTime, 0, -1 do
				ControlBoard.Text = "Intermission: " .. i
				wait(1)
			end
			RunIntermission()
			
		end
	end
end

while wait() do
	if game.Players.NumPlayers >= RequiredPlayers then
		Game()
	end
end

1 answer

✓ Accepted answer

The local function never gets to run, because you call it only within itself. Also, there is no big reason for you to even define that loop as function as you call it only once anyway.

local ControlBoard = workspace:WaitForChild("ControlBoard").Holder.Mode
local Sword = game.ReplicatedStorage:WaitForChild("Sword")
local Maps = game.ReplicatedStorage:WaitForChild("Maps")
local IntermissionTime = 10
local RequiredPlayers = 2
local GameRunning = false
local GameTime = 60

local function Game()
    if GameRunning == false then
        GameRunning = true

	-- This would act same as your function
        for i = IntermissionTime, 0, -1 do
            ControlBoard.Text = "Intermission: " .. i
            wait(1)
        end
    end
end

while wait() do
    if game.Players.NumPlayers >= RequiredPlayers then
        Game()
    end
end

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