Function not working as intended

Hey. I’m currently making system in which players must press a “ready” button to begin the game. Once the value reaches 2, the game starts. I’m using a RemoteEvent to communicate between the client and the server. For each player that clicks the button, the value should only go up by 1, but it goes up by the amount of players already in the game. I only want the value to go up by 1 each time it is pressed. I’ve look around for some answers with no luck. How should I go about fixing this?

Here is the client-side code followed by the server-side code:

-- Get services
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

-- Get the player
local player = Players.LocalPlayer

-- Get elements
local waitingGui = script.Parent.Parent.Parent
local button = script.Parent

-- Check if mouse is hovering over button
local isHovering = false

-- Get events
local updatePlayerCount = ReplicatedStorage.Events.UpdatePlayerCount
local UpdateCharacter1 = ReplicatedStorage.Events.UpdateCharacter1
local UpdateCharacter2 = ReplicatedStorage.Events.UpdateCharacter2
local startGame = ReplicatedStorage.Events.StartGame

-- Function to toggle button and update counter
button.Activated:Connect(function()
	button.Interactable = false
	updatePlayerCount:FireServer()
	
	local value = player:WaitForChild("Appearance", 1000)
	
	if value.Value == 1 then
		UpdateCharacter1:FireServer()
	elseif value.Value == 2 then
		UpdateCharacter2:FireServer()
	end
end)

button.MouseEnter:Connect(function()
	if isHovering == false then
		isHovering = true
		button:TweenSize(UDim2.new(0.159, 0, 0.062, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 0.15, true)
	end
end)

button.MouseLeave:Connect(function()
	if isHovering == true then
		isHovering = false
		button:TweenSize(UDim2.new(0.151, 0, 0.056, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 0.15, true)
	end
end)

-- Function to begin the game
startGame.OnClientEvent:Connect(function()
	print("GAME START")
	waitingGui:Destroy()
end)
-- Get services
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

-- Get events
local updatePlayerCount = ReplicatedStorage.Events.UpdatePlayerCount
local startGame = ReplicatedStorage.Events.StartGame

-- Get maximum player count
local MAX_PLAYERS = 2

-- Function to update player count
updatePlayerCount.OnServerEvent:Connect(function(player)
	task.wait(0.5)
	
	local counter = player.PlayerGui.WaitingGui.Main.Counter
	local counterValue = counter.Value
	
	for index, child in pairs(Players:GetPlayers()) do
		counterValue.Value = counterValue.Value + 1
		counter.Text = (tostring(counterValue.Value).."/"..tostring(MAX_PLAYERS))
	end
	
	if counterValue.Value == MAX_PLAYERS then
		task.wait(0.5)
		startGame:FireAllClients()
	end
end)

In this part:

for index, child in pairs(Players:GetPlayers()) do
		counterValue.Value = counterValue.Value + 1
		counter.Text = (tostring(counterValue.Value).."/"..tostring(MAX_PLAYERS))
	end

You’re telling the server to increase the counterValue for each player in game.

You should remove the unnecessary loop:

updatePlayerCount.OnServerEvent:Connect(function(player)
	task.wait(0.5)
	
	local counter = player.PlayerGui.WaitingGui.Main.Counter
	local counterValue = counter.Value
	
	counterValue.Value = counterValue.Value + 1
	counter.Text = (tostring(counterValue.Value).."/"..tostring(MAX_PLAYERS))
	
	
	if counterValue.Value == MAX_PLAYERS then
		task.wait(0.5)
		startGame:FireAllClients()
	end
end)

This does work but now the counter only updates for the player who pressed the button.