local function start()
if game.Workspace:FindFirstChild("Map") then
game.Workspace.Map:Destroy()
end
local MapClone = game.ReplicatedStorage.Storage.Map:Clone()
MapClone.Parent = workspace
wait(2)
local allPlayers = game.Players:GetChildren()
for i = 1, #allPlayers do
allPlayers[i].Team = game.Teams.game
allPlayers[i].Character.PrimaryPart.CFrame = MapClone.Spawns.Spawn.CFrame
end
game.Workspace.Time.Value.Value = 100
for i = 1,100 do
wait(1)
game.Workspace.Time.Value.Value -= 1
task.wait()
end
local allWinners = game.Teams.game:GetChildren()
for i = 1, #allWinners do
allWinners[i].leaderstats.Wins.Value += 1
task.wait()
end
wait(0.5)
local allPlayers = game.Players:GetChildren()
for i = 1, #allPlayers do
allPlayers[i].Team = game.Teams.lobby
allPlayers[i].Character.PrimaryPart.CFrame = game.Workspace.SpawnLocation.CFrame
end
end
while true do
start()
wait(100)
end
for some reason it waits another 100 seconds after the wait to fire start() again
That’s not how that works, think of functions as portable and reusable code, it works as normal code but can be used anywhere. It also makes it easier as you don’t have to repeat yourself.
If you want that effect, use coroutine or task.spawn
To put it simply, coroutines allow for code to run alongside other code, so if you wanted a loop to run with disrupting the code, you would surround the loop with a coroutine, but if you want to run the code again, you will need to create a new coroutine.
but for the part, you would do:
function Ex()
task.spawn(function()
-- code
end)
end