Hi! Recently, I have been making a round system script for my game, but I have run into an issue. The code I have created only checks if there is less than 2 players once as soon as a player joins the game.
The screenshot above shows what my problem is. It only checks if there is 2 players one time and nothing else. I’ve tried rewriting my script, look at some tutorials, and looked on the Developer Hub. My code is shown below:
-- / VARIABLES /
local IntermissionTimer = 30
local RoundTimer = 300
local RS = game:WaitForChild("ReplicatedStorage")
local MapsFolder = RS.Maps:GetChildren()
local Players = game.Players:GetChildren()
local RoundActive = script.RoundActive
local RoundStatus = script.RoundStatus
-- / CODE /
while true do
if #Players < 2 then -- My attempt on making it check if there are less than 2 players
while true do
RoundStatus.Value = "Not enough players, requirement 2!"
return
end
end
for i = 10, 0, -1 do
RoundStatus.Value = "Intermission "..i
task.wait(1)
end
local RNGMap = MapsFolder[math.random(1, #MapsFolder)]
local MapChosen = RNGMap:Clone()
MapChosen.Parent = game.Workspace
RoundStatus.Value = "Map Chosen: "..MapChosen.Name
task.wait(3)
for i, Player in pairs(game.Players:GetPlayers()) do
local Character = Player.Character
if Player.PlayerScripts.IsPlaying == false then
print("Not Playing")
else
if Character then
local HumRootPart = Character.HumanoidRootPart
HumRootPart.Position = MapChosen.TeleportPoint.Position
end
end
end
for i = 300, 0, -1 do
RoundStatus.Value = "Game: "..i
task.wait(1)
end
for i, Player in pairs(game.Players:GetPlayers()) do
local Character = Player.Character
if Character then
local HumRootPart = Character.HumanoidRootPart
HumRootPart.Position = Vector3.new(5.76, 77.4, -25.73)
end
end
end