How do I do this with my checkpoints using teams?

So basically I want to access a player’s team and I want to make it so that if they are part of a different team that is not the previous team then they cannot go back to the previous checkpoint. Also, I do not want to make checkpoints using leaderstats because that is too complicated for me currently.

`local Stage1 = game.Teams:FindFirstChild(“Stage 1”)

if player.Parent.Team ~= Stage1 then
script.Parent.AllowTeamChangeOnTouch = true
script.Parent.AllowTeamChangeOnTouch = false

I can’t find a way to gain access to the players team. It even didn’t work when I switched it to game.Players:GetPlayerFromCharacter()

1 Like

To acces the player’s team:
Player.Team. Notice that this is not a StringValue but the Team itself, if you want the team’s name just use Player.Team.Name instead.

Changing the AllowTeamChangeOnTouch property on the SpawnLocation will affect all players, not just the one currently hitting the spawn. You might want to use Neutral spawn locations instead, and just handle the team changing by yourself. For example:
You could add an IntValue object inside each SpawnLocation (or an attribute, if you’re up for the challenge).
When a player touches the Neutral SpawnLocation, it should first check if their current checkpoint (this would be another IntValue inside each player) is exactly one number lower than that of the SpawnLocation.
If and only if it is, change the player’s team. You should also change the Player’s RespawnLocation.