You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
detecting getting each players team and print the team name
What is the issue? Include screenshots / videos if possible!
it’s just incorrectly printing
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.
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
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
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.