0

# Owner Teams. [closed]

Say I have an owners team, but I only want it to show up when I join. How would I do it?

### Locked by FearMeIAmLag

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

3
blocco 185
7 years ago

What you would want to do is create a function which is called whenever a player joins. This function would check if the player is the creator of the place. If the player is the creator of the place, it would add a team to the game which only the creator could join. I added some extra functionality to the script, assuming you would want the team to remove itself when you leave, and I added the option for others to join the team when you're gone if it's not deleted (which is disabled by default). I also made it an option to prevent you from joining other teams.

Feel free to look through the code and see how it works.

local preventJoiningOtherTeams = true;
local removeTeamUponExit = true;
local letOthersJoinTeamUponExit = false;
local OwnerTeam = Instance.new("Team")
OwnerTeam.Name = "Team Name"
OwnerTeam.TeamColor = BrickColor.new("Really red")

if player.userId == Game.CreatorId then -- assuming you're the creator
OwnerTeam.AutoAssignable = false
OwnerTeam.Parent = Game:GetService("Teams")
player.TeamColor = OwnerTeam.TeamColor
player.Changed:connect(function(property)
if preventJoiningOtherTeams and property == "TeamColor" and player.TeamColor ~= OwnerTeam.TeamColor then
player.TeamColor = OwnerTeam.TeamColor;
end
end)
end
end

function onPlayerRemoving(player)
if player.userId == Game.CreatorId then
if removeTeamUponExit then
OwnerTeam.Parent = nil -- you might rejoin, so destroying team may be bad
elseif letOthersJoinTeamUponExit then
OwnerTeam.AutoAssignable = true
end
end
end