This post mostly applies to round based games and communicating the game status & countdowns to the client.
I’m currently using a remote event from the server to client to start round countdowns. One issue this has is desyncing (not much of a big deal, I think it could be fixed by sending a remote event every 30 seconds to sync countdowns with server). My current problem is cancelling the countdown loop.
E.x. the intermission countdown starts after enough players are in game, but enough players leave causing the game status to return to “Not enough players” but the client is still stuck on the intermission countdown, sending another remote event would cause the round gui text to overlap. What would be a proper way of handling such things?
-- Client sided, local script
function doCountdown(givenTime)
for i = givenTime, 1, -1 do
givenTime -= 1
roundGUI.Text = formatTime(givenTime)
wait(1)
end
end
local functions = {
NotEnoughPlrs = function()
roundGUI.Text = "Not Enough Players"
end,
Intermission = function(timeGiven)
doCountdown(timeGiven)
end,
}
RemoteEvent.OnClientEvent:Connect(function(funcName, timeGiven)
functions[funcName](timeGiven)
end)
Also how are these systems usually built? Is there a better way than what I’m currently doing?