Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Owner Teams. [closed]

Asked by 10 years ago

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.

Why was this question closed?

2 answers

Log in to vote
3
Answered by
blocco 185
10 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")

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)
0
Thanks. ChandlerTech 5 — 10y
Ad
Log in to vote
-1
Answered by 10 years ago

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)

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. AeonHack 0 — 10y