local fakeChar = game.ServerStorage.PeasantChar -- The character to load
local respawnTime = 2.5 -- How many seconds the player remains dead before they respawn
if game.Players.LocalPlayer.TeamColor == "Brown" then
game.Players.CharacterAutoLoads = false -- Disable default character loading
else
game.Players.CharacterAutoLoads = true
end
function playerAdded(player)
if player.Character and player.Character.Parent then -- Destroy an already-existing character
player.Character:Destroy()
end
while player.Parent do -- Repeat until they leave the game
loadChar(player) -- Method waits until they die
wait(respawnTime)
end
end
function loadChar(player)
local char = fakeChar:clone()
char.Name = player.Name
local humanoid
for i, child in pairs(char:GetChildren()) do -- Find the humanoid
if child.ClassName == "Humanoid" then
humanoid = child
break
end
end
if not humanoid then -- If no humanoid was found, make one
humanoid = Instance.new("Humanoid", char)
end
player.Character = char
char.Parent = game.Workspace
humanoid.Died:wait() -- Wait until they die
end
game.Players.PlayerAdded:connect(playerAdded)
for i, player in pairs(game.Players:GetPlayers()) do -- Play Solo support
if player.Character then
player.Character:Destroy()
end
playerAdded(player)
end
I am trying to make it so that unless you are on the teamcolor brown, your character does not auto load, but I am getting an error on line 4:" ServerScriptService.CharLoader:4: attempt to index nil with 'TeamColor' " Could someone please explain the correct way to check if the player is on a certain team?

2 comments
is this a script or local script?
serverscript