I am making a main script for my game which controls the rounds and players, but my code is skipping and breaking at a certain point for reasons I don't understand. Here is my code:
math.randomseed(tick())
repstorage = game.ReplicatedStorage
status = repstorage.Status
while wait() do
for i = 10, 1, -1 do
status.Value = "Intermission: "..i
wait(1)
end
status.Value = "Choosing Map..."
wait(5)
chanceMap = math.random(1,1)
if chanceMap == 1 then
repstorage.Maps.Map1:Clone().Parent = game.Workspace
status.Value = "Map Chosen: Symmetrical Maze!"
wait(5)
end
status.Value = "Get Ready!"
wait(5)
repstorage.Teams.Fighters:Clone().Parent = game.Teams
wait(0.2)
for i, player in ipairs(game.Players:GetPlayers()) do
if player.Character then
local hum = player.Character:FindFirstChild('Humanoid')
if hum then
player.TeamColor = BrickColor.new("Really red")
repstorage.Weapons.M4:Clone().Parent = player.StarterGear
repstorage.Weapons.M9:Clone().Parent = player.StarterGear
wait(0.2)
player:LoadCharacter()
end
end
end
This is where it breaks. It stops displaying the status values and seems to skip to changing the players team, respawning me in the lobby and then seems break the while loop. I can tell because when I change the brickcolor to the fighter team colour, it respawns me in the arena and not the lobby. The waits and while loops don't seem to register at all.
status.Value = "Begin!"
wait(5)
for i = 10, 1 -1 do
status.Value = "Game In Progress..."
wait(1)
end
for i, player in ipairs(game.Players:GetPlayers()) do
if player.Character then
local hum = player.Character:FindFirstChild('Humanoid')
if hum then
player.TeamColor = BrickColor.new("Institutional white")
player.StarterGear:ClearAllChildren()
wait(0.2)
player:LoadCharacter()
wait(0.1)
end
end
end
status.Value = "Game Over!"
wait(5)
end

1 comment
this is exactly what happened to me so I had to put my script in a local script in starter player scripts, idk if this script will work if u do what i did but, give it a try