Script not giving players wins?

My script:

		local allWinners = game.Teams.game:GetChildren()
		for i = 1, #allWinners do
			print(allWinners[i].Name)
			allWinners[i].leaderstats.Wins.Value += 1
			task.wait()
		end

does not give any wins or error and prints nothing? (there are players in that team)

is this in a server script or local script?
also, you dont have to put a wait in a for loop

it is a server fdsfdsffsdfdsgdfgfdgfd

are you sure allWinners contains player instances?
it might be just the names of the players

it finds all the players yes it find the instances

then the code probably fails to reach this point, can you post whole code?

It does not fail to reach this as it does the next loop after:

wait(3)
local function start()
	task.spawn(function()
		if game.Workspace:FindFirstChild("Map") then
			game.Workspace.Map:Destroy()
		end
		local MapClone = game.ReplicatedStorage.Storage.Map:Clone()
		MapClone.Parent = workspace
		wait(2)
		local allPlayers = game.Players:GetChildren()
		for i = 1, #allPlayers do
			allPlayers[i].Team = game.Teams.game
			allPlayers[i].Character.PrimaryPart.CFrame = MapClone.Spawns.Spawn.CFrame
		end
		game.Workspace.Time.Value.Value = 10
		for i = 1,10 do
			wait(1)
			game.Workspace.Time.Value.Value -= 1
			task.wait()
		end
		local allWinners = game.Teams.game:GetChildren()
		for i = 1, #allWinners do
			print(allWinners[i].Name)
			allWinners[i].leaderstats.Wins.Value += 1
		end
		wait(0.5)
		local allPlayers = game.Players:GetChildren()
		for i = 1, #allPlayers do
			allPlayers[i].Team = game.Teams.lobby
			allPlayers[i].Character.PrimaryPart.CFrame = game.Workspace.SpawnLocation.CFrame
		end
	end)
end
while true do
	start()
	wait(20)
end

you said it doesn’t print so the size of allWinners must be 0,
are you sure there are players inside that team?

I am sure I tested the game and I am in the team it also should print the names of the players but something isint working

Does this work?

task.wait(3)
local function start()
	task.spawn(function()
		if game.Workspace:FindFirstChild("Map") then
			game.Workspace.Map:Destroy()
		end
		local MapClone = game.ReplicatedStorage.Storage.Map:Clone()
		MapClone.Parent = workspace
		task.wait(2)
		local allPlayers = game.Players:GetPlayers()
		for i = 1, #allPlayers do
			allPlayers[i].Team = game.Teams.game
			allPlayers[i].Character.PrimaryPart.CFrame = MapClone.Spawns.Spawn.CFrame
		end
		game.Workspace.Time.Value.Value = 10
		for i = 1,10 do
			task.wait(1)
			game.Workspace.Time.Value.Value -= 1
			task.wait()
		end
		local allWinners = game.Teams.game:GetPlayers()
		for i = 1, #allWinners do
			print(allWinners[i].Name)
			allWinners[i].leaderstats.Wins.Value += 1
		end
		task.wait(0.5)

		for i = 1, #allPlayers do
			allPlayers[i].Team = game.Teams.lobby
			allPlayers[i].Character.PrimaryPart.CFrame = game.Workspace.SpawnLocation.CFrame
		end
	end)
end
while true do
	start()
	task.wait(20)
end

To get all of the players on a team you use Team:GetPlayers

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