The team change is during the intermission, which then waits 30 seconds and the print script runs.
Very confusing as to why it doesn’t work. Before the print script runs, it is also clear my team is listed as ‘Green’ or ‘Blue’
--I simplified it to just one team to see the result.
while true do
wait(10)
game.Players.Fruxan.Team = game:GetService('Teams').Green
wait(30)
print(game.Players.Fruxan.Team.Name)
end
--No different results.
That script doesn’t randomize whether you will be placed on Green or Blue team, for sure. It should always print Green because you set yourself to have Green team.
Are you sure that the script printed Lobby, and not other scripts?
I had simplified it to just changing the team to Green instead of randomizing, just to test. Also yes, as those are the only scripts I used in my ‘Test’ place.
That’s basically what I want to do. I want to make an if statement, if the players team is green then respawn the player etc. Problem is, it keeps saying it’s not on green team, and its still in the lobby team.
I wrote a slightly more complex version of your script to verify the issue. This is running in a Script parented to ServerScriptService
local playerService = game:GetService("Players")
local teamService = game:GetService("Teams")
playerService.PlayerAdded:Connect(function (player)
local teams = teamService:GetChildren()
local i = 0
while wait(1) do
i = (i + 1) % #teams
local oldTeam, newTeam = player.Team, teams[i + 1]
player.Team = newTeam
print(oldTeam, newTeam, player.Team)
end
end)
I am not observing the issue you are referring to.
Perhaps you’re setting the team from the client when you should be setting it from the server?