Player team is printing incorrect team

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    detecting getting each players team and print the team name
  2. What is the issue? Include screenshots / videos if possible!
    it’s just incorrectly printing
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have tried changing it around but the only thing that prints correctly is if I use a local script (possible but very would rather stay in server for ease)
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
    Its a server script and each team has one player
-- the game would start up here 
for i, v in pairs(game:GetService("Players"):GetPlayers()) do
	
	if v.Team == game.Teams["1"] then
		print("team 1 ")
	elseif v.Team == game.Teams["2"] then
		print(" team 2 ")
	elseif v.Team == game.Teams["3"] then
		print("team 3")
	end
end

if i were say team 1 or 2 it would always print 3
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

try this instead?

for i, v in pairs(game:GetService("Players"):GetPlayers()) do
	
	if v.Team == game.Teams["1"] then
		print("team 1 ")
end
	if v.Team == game.Teams["2"] then
		print(" team 2 ")
	end
if v.Team == game.Teams["3"] then
		print("team 3")
	end
end

tried it but still incorrect, starting to think this must be a bug where server just doesn’t understand teams

How are the teams being assigned to players?

They just have the auto assignable property

According to your script, the team check happens when the game starts up. What if you waited some time before checking?

it doesnt start when the game starts, at first i thought that was the issue but it i added a wait of 20 seconds before hand

Is something changing the team on a local script? I don’t see many reasons why it would print the wrong team.

the crazy thing is is that I don’t have anything on local scripts. I’m running it in a test place and its still printing incorrectly

i found a little workaround in local and although I would rather not use it, it seems like I’m cornered here

What if you inserted print(v.Team.Name) at the start of the loop code? It could say something different than what is printed in the if statements

they say the same thing sadly

insert random wordsss

So they still both say “3” and then “team 3” even with team 1 or 2? Unfortunately, I don’t have any other ideas, maybe try writing the code in a different way or something, the only thing I can think of is trying to change is :GetPlayers() to :GetChildren() because sometimes Lua does weird things

‘prints correctly is if I use a local script’ - This makes me believe that the players team is getting changed locally.

Well I tried printing their team in a local script to see if it’s I correct but it’s seems fine

I think ima suck it up and use a local script and remote function just to bot waste time

Or you could do as suggested and change the player’s team from the server via server script such that the change of the player’s “Team” property is correctly replicated to the server.

This may help.