My code keeps on slowing down, to the point where after 10 rounds it takes 5 seconds to do 1 second on round one. Any ideas what it could be? here is my main server script:
local UpdateEvent = Instance.new("RemoteEvent")
UpdateEvent.Name = "UpdateIntermission"
UpdateEvent.Parent = game.ReplicatedStorage
local Teams = game:GetService("Teams")
_G.Start = false
_G.playing = false
_G.stop = true
function start()
_G.Prepare = true
local intermission = 0
for intermission = 1,30 do --possibly this?
UpdateEvent:FireAllClients(intermission)
wait(1)
end
_G.Start = true
wait(0.1)
_G.Start = false
for i, player in ipairs(game.Teams.Spectators:GetPlayers()) do
--game starts
end
_G.playing = true
end
while true do
if #game.Teams.Spectators:GetPlayers() > 0 and _G.playing == false then --default 1 |At least one person spectating
start()
elseif #game.Players:GetPlayers() < 1 and _G.playing == false then --default 0|More than 0
_G.playing = false
end
wait()
end

2 comments
global variables are slow.
would shared variables be any better?