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

How do I make "teams" appear and disappear when someone joins/leaves?

Asked by 10 years ago

I need to make it so that when someone from a specific group joins, it will create a Team and name it and everything, but I also need it to leave when they go away. Here's what I have so far:

function onPlayerEntered(plyr)
if plyr:IsInGroup(1094909) then
    if game.Teams:findFirstChild("Swedish Security Service") == nil then
        SS = Instance.new("Team")
        SS.Parent = game.Teams
        SS.Name = "Swedish Security Service"
        SS.TeamColor = BrickColor.new("Navy blue")
    end
plyr.TeamColor = BrickColor.new("Navy blue")
plyr.Neutral = false
end
if plyr:IsInGroup(1094871) then
    if game.Teams:findFirstChild("Swedish Military") == nil then
        SS = Instance.new("Team")
        SS.Parent = game.Teams
        SS.Name = "Swedish Military"
        SS.TeamColor = BrickColor.new("Earth green")
    end
plyr.TeamColor = BrickColor.new("Earth green")
plyr.Neutral = false
end
end

game.Players.PlayerAdded:connect(onPlayerEntered)

Answer this question