How to make round system that starts the game when thereres more than 1 player?

Ive been trying to make this system where the game starts when there is more than 1 player in game but it just doesnt start when i test the game with 1 or more players, instead it gets broken and im not really sure why, i tried to search through devforum and no help, so if you know anything or can make it simplier i will really appreciate it

local plramount = game.ReplicatedStorage.PlayersAmount

while true do
	rs.EndRound:FireAllClients()
	
	votingfolder.MapVoteModel1.MapVotePlate1.CanTouch = false
	votingfolder.MapVoteModel2.MapVotePlate2.CanTouch = false
	votingfolder.MapVoteModel3.MapVotePlate3.CanTouch = false
	
	if plramount.Value > 1 then
		for _, player in next, players:GetPlayers(), nil do
			player:SetAttribute("InGame", false) --set the player's attribute
		end

		for i = 10, 0, -1 do
			status.Value = "Intermission: "..i
			task.wait(1)
		end
		status.Value = "Map voting"
		votingfolder.MapVoteModel1.MapVotePlate1.CanTouch = true
		votingfolder.MapVoteModel2.MapVotePlate2.CanTouch = true
		votingfolder.MapVoteModel3.MapVotePlate3.CanTouch = true
		task.wait(10)

		votingfolder.MapVoteModel1.MapVotePlate1.CanTouch = false
		votingfolder.MapVoteModel2.MapVotePlate2.CanTouch = false
		votingfolder.MapVoteModel3.MapVotePlate3.CanTouch = false

		local votes1 = votingfolder.MapVoteModel1.Votes1Counter.Value
		local votes2 = votingfolder.MapVoteModel2.Votes2Counter.Value
		local votes3 = votingfolder.MapVoteModel3.Votes3Counter.Value

		print("Votes1: " .. votes1)
		print("Votes2: " .. votes2)
		print("Votes3: " .. votes3)

		if votes1 > votes2 and votes1 > votes3 then
			status.Value = "Map 1 wins..."
		elseif votes2 > votes1 and votes2 > votes3 then
			status.Value = "Map 2 wins..."
		elseif votes3 > votes1 and votes3 > votes2 then
			status.Value = "Map 3 wins..."
		else
			status.Value = "Tie, random map will be chosen..."
		end

		task.wait(2)
		rs.StartRound:FireAllClients()

		for _, player in next, players:GetPlayers(), nil do
			player:SetAttribute("InGame", true) --set the player's attribute
		end

		for i = 10, 0, -1 do
			status.Value = "Game: "..i
			task.wait(1)
		end
	end
end

script that stores all players amount in game

while wait() do
	script.Parent.Value = #game.Players:GetPlayers()
end
1 Like

Why not just calculate the player amount in the script that needs it?
Also, please add a wait inside the while true do loop, as when there isn’t more than one player, the code wouldn’t yield ever. Also also, use task.wait() instead of wait()

1 Like

try

local Players = game:GetService("Players")
numOfPlayers = #Players:GetPlayers()

your local plramount = game.ReplicatedStorage.PlayersAmount.Value may be incorrect so instead use #Players:GetPlayers()

1 Like

Might help you

guys i found a solution (and i didnt definitely use AI for this lol)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.