I want to give players a win

Hey so I am making a game and I want to give players a win after the 10th round. I made the leaderstats script already but I am unsure of how to make the script to give ALL players in the server the win. Also, i will place the “give player 1 win” script in my main frame script placed in server script service ( so i cant use LocalPlayer)

Loop through the players and give each player +1 win

local Players = game:GetService("Players")

for _, Player in pairs(Players:GetChildren()) do
	local leaderstats = Player.leaderstats
	local Wins = leaderstats.Wins
	
	Wins.Value = Wins.Value +1
end
1 Like

This but change:

Wins.Value = Wins.Value +1

for:

Wins.Value += 1

Don’t give me the solution mark.

local Players = game:GetService("Players")

for _, Player in ipairs(Players:GetPlayers()) do
	local Wins = Player.leaderstats.Wins
	Wins.Value += 1
end
2 Likes

This is how you would give every player a win.

local c = game.Players:children()
for i = 1, #c do -- c[i] = a player
	if c[i]:FindFirstChild("leaderstats") ~= nil then 
	if c[i].leaderstats:FindFirstChild("Wins") then c[i].leaderstats.Wins.Value = c[i].leaderstats.Wins.Value + 1 end end
end
1 Like

Thanks for the reply, worked first try