Hello, thank you for reading. What I'm trying to do is make a team where there is a limit. What I'm trying to do is make a IntValue which adds +1 to itself each time a player is identified as a player who is on the prison guard team. It is not working and I don't know why.
The other problem is that once a player leaves the server, I want the script to recheck if the person who left was on the prisoner team. If he was, then the IntValue will be subtracted by 1.
If anyone can help me with these two problems, I'll be so grateful towards you.
GuardCount = game.Workspace.GuardCount
players = game.Players:getChildren()
function addGuards()
for i = 1, #players do
if players[i].Character ~= nil then
if players[i].TeamColor == game.Teams.PrisonGuard.TeamColor then
GuardCount.Value = GuardCount.Value + 1
end
end
end
end
game.Players.ChildAdded:connect(addGuards)

1 comment
You will have to make the client check whether or not it is okay to enter the team. In addition, use PlayerAdded instead of ChildAdded for getting the players.