Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Owner Teams.

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

2 answers

✓ Accepted answer

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")

function onPlayerAdded(player)
	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

Game:GetService("Players").PlayerAdded:connect(onPlayerAdded)
Game:GetService("Players").PlayerRemoving:connect(onPlayerRemoving)

1 comment

0

Thanks.

group = 133867 -- change to group ID deb = true function Check(p) if p ~= nil then deb = false local human = p.Parent if human ~= nil then local player = game.Players:GetPlayerFromCharacter(human) if player ~= nil then if player:IsInGroup(group) then player.TeamColor = BrickColor.new("Bright green") end end end end end script.Parent.Touched:connect(Check)

1 comment

0

That is basicly what you gotta put just change group ID to your groups Id and if this isnt what you were looking for I am terribly sorry.

This discussion is preserved as it was. New answers, comments, and votes are closed.