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

How to give a specific team to a player if you are named as my name?

Asked by 3 years ago
Teams = game:GetService("Teams")



local Ownerz = Instance.new("Team")
Ownerz.Name = "Ownerz"
Ownerz.TeamColor = BrickColor.new("Forest green")

local Friends = Instance.new("Team")
Friends.Name = "Friends"
Friends.TeamColor = BrickColor.new("Dark blue")

local Ordinarys = Instance.new('Team')
Ordinarys.Name = "Ordinarys"
Ordinarys.TeamColor = BrickColor.new("Bright red")

game.Players.PlayerAdded:Connect(function(player)
    if player.Name == "MyFriendsName" then
        player.Teams = Teams.Friends
        elseif player.Name == "CountOnMeBro" then
        player.Teams = Teams.Ownerz
    else
        player.Teams = Teams.Ordinarys
    end
end)

The teams don't show up and it doesn't change my team to Ownerz

1 answer

Log in to vote
0
Answered by
3F1VE 257 Moderation Voter
3 years ago

Hello, I do not recommend using it by name since if you change your name then you have to update it every time use it by UserId (By the way you forgot to parent Ownerz, Friends and Ordinarys)

local Teams = game:GetService("Teams")

local Ownerz = Instance.new("Team",Teams)
Ownerz.Name = "Ownerz"
Ownerz.TeamColor = BrickColor.new("Forest green",Teams)

local Friends = Instance.new("Team,Teams")
Friends.Name = "Friends"
Friends.TeamColor = BrickColor.new("Dark blue")

local Ordinarys = Instance.new('Team',Teams)
Ordinarys.Name = "Ordinarys"
Ordinarys.TeamColor = BrickColor.new("Bright red")

game.Players.PlayerAdded:Connect(function(player)
    if player:IsFriendsWith(1533246993) then
        player.Teams = Teams.Friends
        elseif player.UserId == 1533246993 then
        player.Teams = Teams.Ownerz
    else
        player.Teams = Teams.Ordinarys
    end
end)

Ad

Answer this question