Problem with checkpoint system, team color isn't changing

Hi, I’m trying to create a checkpoint system for my game. For some reason the script isn’t changing the team color when I touch the checkpoint.

Here’s a video showing the problem:

The script:

local player = game:GetService("Players").LocalPlayer
player.TeamColor = game.Teams.LVL1.TeamColor
local Pspawn = game.Workspace.Pspawn

while true do
    wait(1)
    if player.TeamColor ~= Pspawn.TeamColor then
        Pspawn.AllowTeamChangeOnTouch = false 
    end
end

Thanks for your help!

Switching teams through touching a Spawn is handled on the server, and therefore changing that property on the client would have change the functionality of the spawn and would cause the issue that you have posted about.

Because of this, your best solution would likely to be to disable that property on all of the spawns, and create your own code to handle when players touch spawn locations.

1 Like

The real issue is the spawn checkpoint is changing my team, even though the AllowTeamChangeOnTouch property is sat to false. Can you confirm or specify if your reply still matches this?

1 Like

Yes, this is what I am stating. Changing AllowTeamChangeOnTouch on your client (as in through a local script) does not actually work as AllowTeamChangeOnTouch is only recognized by the server, which is what handles changing player teams.

1 Like

Wouldn’t you need to use a remote event for this? Why couldn’t you just use a remote event on the property instead of creating your own function?

1 Like

I assume that your game is multi-player, and so if you disable a spawn on the server it would disable it for all players and not just the player who has reached the checkpoint. However, if your game is single-player, just using a remote event would suffice, though, it’d be much more efficient and simpler to just make a server script to do it.

1 Like

How would I make a server script that effects all players, individually. Can you give an example of defining a player like in a local script (player = game:GetService(“Players”)localPlayer? Or smth. I’m kinda confused on this sorry. It’s multiplayer as well.