I am trying to make a round system from a tutorial, and ended up adding new code to have players spawn at random spawn locations instead of 1 single place. My problem is these 3 ends after. It won’t go on the the part where it updates the status value because it ends prematurely. How can I change this?
local roundlength = 1
local inround = game.ReplicatedStorage.Inround
local status = game.ReplicatedStorage.Status
inround.Changed:Connect(function()
if inround.Value == true then
task.wait(1) -- Can be removed later
local Players = game:GetService("Players")
local spawns = workspace.Map.Spawns:GetChildren()
local plrList = Players:GetPlayers()
task.wait(2) -- Can be removed later
for _, plr in pairs(plrList) do
local num = math.random(1, #spawns)
local rootPart = plr.Character.HumanoidRootPart
print(plr)
rootPart.CFrame = spawns[num].CFrame
end
else
task.wait(1) -- Can be removed later
local Players = game:GetService("Players")
local LobbySpawns = workspace.Lobby.Spawns:GetChildren()
local plrList = Players:GetPlayers()
task.wait(2) -- Can be removed later
for _, plr in pairs(plrList) do
local num = math.random(1, #LobbySpawns)
local rootPart = plr.Character.HumanoidRootPart
print(plr)
rootPart.CFrame = LobbySpawns[num].CFrame
end
end
end)
local function Round()
while true do
inround.Value = false
for i = intermission,0,-1 do
status = "Game will start in "..i.." seconds!"
wait(1)
end
inround.Value = true
for i = roundlength,0,-1 do
status = "Game will end in "..i.." seconds!"
wait(1)
end
end
end
spawn(Round)```
everything after
in this script is supposed to change the game status which is tied to a textlabel. It never gets to that point though because I have these here
which tells it to end before it can get to that section and thusly the status never changes, the round system itself functions but the text does not update and count down
local roundlength = 1
local intermission = 1
local inround = game.ReplicatedStorage.Inround
local status = game.ReplicatedStorage.Status
inround.Changed:Connect(function()
if inround.Value == true then
task.wait(1) -- Can be removed later
local Players = game:GetService("Players")
local spawns = workspace.Map.Spawns:GetChildren()
local plrList = Players:GetPlayers()
task.wait(2) -- Can be removed later
for _, plr in pairs(plrList) do
local num = math.random(1, #spawns)
local rootPart = plr.Character.HumanoidRootPart
print(plr)
rootPart.CFrame = spawns[num].CFrame
end
else
task.wait(1) -- Can be removed later
local Players = game:GetService("Players")
local LobbySpawns = workspace.Lobby.Spawns:GetChildren()
local plrList = Players:GetPlayers()
task.wait(2) -- Can be removed later
for _, plr in pairs(plrList) do
local num = math.random(1, #LobbySpawns)
local rootPart = plr.Character.HumanoidRootPart
print(plr)
rootPart.CFrame = LobbySpawns[num].CFrame
end
end
end)
function Round()
while true do
inround.Value = false
for i = intermission,0,-1 do
status = "Game will start in "..i.." seconds!"
wait(1)
end
inround.Value = true
for i = roundlength,0,-1 do
status = "Game will end in "..i.." seconds!"
wait(1)
end
end
end
spawn(Round)
Maybe if you sent us the whole thing we could figure it out? Just by taking a glance at the code I can’t really seem to figure out what’s wrong besides the fact that intermission is not defined.
What does spawn(round) do? I’m not a pro so I’m not familiar with how spawn fires.
Does it only fire once? If it only fires the one time then the round function only fires once.
local roundlength = 1
local intermission = 1
local inround = game.ReplicatedStorage.Inround
local status = game.ReplicatedStorage.Status
inround.Changed:Connect(function()
if inround.Value == true then
task.wait(1) -- Can be removed later
local Players = game:GetService("Players")
local spawns = workspace.Map.Spawns:GetChildren()
local plrList = Players:GetPlayers()
task.wait(2) -- Can be removed later
for _, plr in pairs(plrList) do
local num = math.random(1, #spawns)
local rootPart = plr.Character.HumanoidRootPart
print(plr)
rootPart.CFrame = spawns[num].CFrame
end
else
task.wait(1) -- Can be removed later
local Players = game:GetService("Players")
local LobbySpawns = workspace.Lobby.Spawns:GetChildren()
local plrList = Players:GetPlayers()
task.wait(2) -- Can be removed later
for _, plr in pairs(plrList) do
local num = math.random(1, #LobbySpawns)
local rootPart = plr.Character.HumanoidRootPart
print(plr)
rootPart.CFrame = LobbySpawns[num].CFrame
end
end
end)
function Round()
while true do
inround.Value = false
for i = intermission,0,-1 do
status.Value = "Game will start in "..i.." seconds!"
wait(1)
end
inround.Value = true
for i = roundlength,0,-1 do
status.Value = "Game will end in "..i.." seconds!"
wait(1)
end
end
end
spawn(Round)