Intermission System [Help]

So i’m trying to make an intermission system where:

  • At least 2 players need to be ‘ready’ for the intermission to start
  • The intermission cancels if there is only 1 player ready inbetween the countdown/map selecting/mode selecting.

I’ve pretty much scripted it, and it works fine. Only thing is that it’s 250 lines, which for a simple intermission system is alot. It’s also very inefficient. There’s a for loop pretty much everywhere where it checks how many players have ‘ready’, and some other junk.

So i have a plan. Instead of having these for loops everywhere, which clog everything up, i’ll make it check how many players have the value ‘ready’ everytime a player presses ‘ready’ (with a remote event).

However, i don’t know how to implement it in the system so that is passes on a value, while keeping the criteria i’ve listed above

local remoteEvent = -- path to RemoteEvent
remoteEvent.OnServerEvent:Connect(funtion(plr)
    local tag = Instance.new("BoolValue")
    tag.Name = "Ready"
    tag.Parent = plr
end)

-- inside the intermission loop

local readyPlayers = {}
for _, plr in pairs(game.Players:GetPlayers()) do
    if plr:FindFirstChild("Ready") then
        table.insert(readyPlayers, plr)
    end
end

if #readyPlayers <= 1 then
    print("not enought players!")
    break
end

Make sure to delete all the tags when the intermission is over:

for _, plr in pairs(game.Players:GetPlayers()) do
    local tag = plr:FindFirstChild("Ready")
    if tag then
        tag:Destroy()
    end
end

I hope this helps :slightly_smiling_face: