How to stop value adding when on a specific team

Im in noob tem, it doesnt print anything but prints nothing

local Players = game:GetService("Players")
local teams = game:GetService("Teams")
local tof = false
local function leaderboardSetup(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player

	local times = Instance.new("IntValue")
	times.Name = "times"
	times.Value = 0
	times.Parent = leaderstats
	while true do
		task.wait(1)
		print(CheckTeam(player))
		times.Value += 1
	end
end

function CheckTeam(plr)
	local teams = teams:GetTeams()
	for _, team in pairs(teams) do
		print("print 1")
		local players = team:GetPlayers()
		for _, player in pairs(players) do
			print("print 2")
			if player == plr then
				return team.Name
			end
		end
	end
	return false
end

Players.PlayerAdded:Connect(leaderboardSetup)

lets see what happened

prints 1 and false
ssssssssssssssssssss

there no print 2? jfeuewhwknju

nop even if they change teams
sdhlgsiukdtfuksefyhsiu

sorry, i cant help you any longer. That the best i can do. bye. Also maybe you can check why there no print 2, my expectation. that players array is empty or nil

local players = team:GetPlayers()