Need to give players a win whenever round 10 is over

Hey so I am making a color block game with 10 rounds and when players reach round 10, i want to give them a “WIN”. I already made the leaderboard for it :

local DataStoreService = game:GetService("DataStoreService")

local DataStore = DataStoreService:GetDataStore("GamesPlayed")



game.Players.PlayerAdded:Connect(function(Player)

local Leaderstats = Instance.new("Folder")

Leaderstats.Name = "leaderstats"

Leaderstats.Parent = Player

local PlayerWins = Instance.new("StringValue")

PlayerWins.Name = "Wins"

PlayerWins.Value = DataStore:GetAsync(Player.UserId) or 0

PlayerWins.Parent = Leaderstats

end)

game.Players.PlayerRemoving:Connect(function(Player)

DataStore:SetAsync(Player.UserId, Player.leaderstats.Wins.Value)

end)

The issue is I don’t know where to input +1 win in my mainframe script :

while true do
	



	local Timer = 31

	for i = Timer, 0, -1 do
		task.wait(1)
		print(i)
	end																	-- Intermission timer

	local Round = 0

	local StarterBlock = game.Workspace.StarterBlock






	for i=1,3 do


		Circles = game.Workspace.Circles:GetChildren() 

		Chosen_Colour = Circles[math.random(1,#Circles)]

		game.ReplicatedStorage.Colour.Value = Chosen_Colour.Name    --- ROUND 1 AND 2

		task.wait(6)

		StarterBlock.Transparency = 1
		StarterBlock.CanCollide = false 

		wait(2)

		for number,Circle_Colours in pairs(Circles) do
			for number,Circle_Part in pairs(Circle_Colours:GetChildren()) do

				Circle_Part.Transparency = 1 
				Circle_Part.CanCollide = false
			end
		end

		for number, Circle_Part in pairs(Chosen_Colour:GetChildren()) do
			Circle_Part.Transparency = 0 
			Circle_Part.CanCollide = true
		end

		wait(3) -- waits again

		for number,Circle_Colours in pairs(Circles) do 
			for number,Circle_Part in pairs(Circle_Colours:GetChildren()) do
				print("h")
				Circle_Part.Transparency = 0
				Circle_Part.CanCollide = true

				Round += 1	
			end
		end
	end



	print("Round 1, 2 and 3 completed")





	for i=1,2 do

		Circles = game.Workspace.Circles:GetChildren() 

		Chosen_Colour = Circles[math.random(1,#Circles)]

		game.ReplicatedStorage.Colour.Value = Chosen_Colour.Name 

		task.wait(5)
		-- ROUND 4,5
		for number,Circle_Colours in pairs(Circles) do
			for number,Circle_Part in pairs(Circle_Colours:GetChildren()) do

				Circle_Part.Transparency = 1 
				Circle_Part.CanCollide = false
			end
		end

		for number, Circle_Part in pairs(Chosen_Colour:GetChildren()) do
			Circle_Part.Transparency = 0 
			Circle_Part.CanCollide = true
		end

		wait(3) 

		for number,Circle_Colours in pairs(Circles) do 
			for number,Circle_Part in pairs(Circle_Colours:GetChildren()) do
				print("h")
				Circle_Part.Transparency = 0
				Circle_Part.CanCollide = true

				Round += 1
			end
		end
	end

	print("Round 4, 5 and 6 completed")






	for i=1,3 do

		Circles = game.Workspace.Circles:GetChildren() 

		Chosen_Colour = Circles[math.random(1,#Circles)]

		game.ReplicatedStorage.Colour.Value = Chosen_Colour.Name 

		task.wait(3)
		-- Round 6,7,8
		for number,Circle_Colours in pairs(Circles) do
			for number,Circle_Part in pairs(Circle_Colours:GetChildren()) do

				Circle_Part.Transparency = 1 
				Circle_Part.CanCollide = false
			end
		end

		for number, Circle_Part in pairs(Chosen_Colour:GetChildren()) do
			Circle_Part.Transparency = 0 
			Circle_Part.CanCollide = true
		end

		wait(3)

		for number,Circle_Colours in pairs(Circles) do 
			for number,Circle_Part in pairs(Circle_Colours:GetChildren()) do
				print("h")
				Circle_Part.Transparency = 0
				Circle_Part.CanCollide = true

				Round += 1
			end
		end
	end

	print("Round 6,7 and 8 completed")







	for i=1,2 do

		Circles = game.Workspace.Circles:GetChildren() 

		Chosen_Colour = Circles[math.random(1,#Circles)]

		game.ReplicatedStorage.Colour.Value = Chosen_Colour.Name 

		task.wait(2)
		-- ROUND 9,10
		for number,Circle_Colours in pairs(Circles) do
			for number,Circle_Part in pairs(Circle_Colours:GetChildren()) do

				Circle_Part.Transparency = 1 
				Circle_Part.CanCollide = false
			end
		end

		for number, Circle_Part in pairs(Chosen_Colour:GetChildren()) do
			Circle_Part.Transparency = 0 
			Circle_Part.CanCollide = true
		end

		wait(3) 

		for number,Circle_Colours in pairs(Circles) do 
			for number,Circle_Part in pairs(Circle_Colours:GetChildren()) do
				print("h")
				Circle_Part.Transparency = 0
				Circle_Part.CanCollide = true

				Round += 1


				local StarterBlock = game.Workspace.StarterBlock

				StarterBlock.Transparency = 0
				StarterBlock.CanCollide = true


			end
		end
	end
	print("Round 9 and 10 completed")
end

Any help is appreciated

1 Like

If you want to give them a win after end of round 10 you’d just put it under the last print statement but make sure you know whos left in the game so you give it to right person.

1 Like

Thanks for the reply. Onviously after the print statement but when i try giving all players the win, i get an error. Here is the code i put after the 10th round (serverscriptservice)


local WinStat = Player:WaitForChild("leaderstats"):WaitForChild("Wins"
WinStat.Value +=1