Script to change a player's team not working

This script is supposed to take the player who loses a mini game and change their team from “Elimination Trial” to “Spectator”. The mini game is working as intended, and when it’s done it leaves the player who is supposed to be eliminated as the only player in the elimination trial team. For some reason, when this part of the script runs it just skips over it completely, leaving the one player stuck in this team but continuing on with the rest of the code. Anyone know why that is?

    local eplayer
	local eteam = game.Teams["Elimination Trial"]:GetPlayers()
	if #eteam ~= 0 then
		eplayer = eteam[1]
		displayText(eplayer.NameItems.Nickname.Value .. " came last in the elimination trial and has been eliminated from the game.")
		eplayer.Team = game.Teams.Spectators

Try using game:GetService("Teams") instead of game.Teams

1 Like