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

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

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

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)

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