I've been trying to make this script. It's supposed to check if the player's deaths == 11 and then changes their team to Spectators, and respawns them.
player = game.Players:WaitForChild("LocalPlayer")
if player.leaderstats.deaths.Value == 11 then
player.TeamColor = BrickColor.new("White")
player:LoadCharacter()
end

5 comments
Since it's a local script inside StarterGui, each time the player respawns that code will run.
Ah, I didn't realize it was in the StarterGui.
It's a Script in ServerScriptService and it still doesnt work :(
Disconnected event because of expectation.
I'm not sure if LocalScript run in the ServerScriptService. Put it into the StarterGui and see what happens.