Owner/Admin only teams?

I am creating a scp-like game and I’d like to make a system that will change my team when I join but im not sure how I would do it.

(Using the team system that’s built into studio)

1 Like

Use PlayerAdded function and check the players ID to an array of allowed user id’s and change their team.

Example:

local Players, Teams = game:GetService("Players"), game:GetService("Teams") -- Get Services

local Admins = { -- Array of UserIds
    113914723, -- Your UserId
    1234, -- If you want to add more, just put the ID and then "," after.
}

Players.PlayerAdded:Connect(function(player) -- Player joins
    for index, id in pairs(Admins) do -- Loop through all of the IDs
        if player.UserId == id then -- Check if the ID matches
            player.Team = Teams:FindFirstChild("Admins") -- Set their team, replace "Admins" with the name of your team.
        end
    end
end)
4 Likes
local Game = game
local Players = Game:GetService("Players")

local Admins = {
	[1] = true,
	[Game.CreatorId] = true
}

local function OnPlayerAdded(Player)
	if not Admins[Player.UserId] then return end
	--Player is an admin.
end

Players.PlayerAdded:Connect(OnPlayerAdded)
2 Likes