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

How do you make specific players join certain teams/roles based on username?

I have been trying to do this for a while (the original script I tried eventually stopped working so now I have been trying to make a system for it) where based on someone's username they will go into a certain role/team.

I have used this (which is a ban list) from a youtube video and tested it on myself (and it works):

local message = "I do not forget..."
local banlist = {
	Phaibun = true,
}

game.Players.PlayerAdded:Connect(function(player)
	if banlist[player.Name] then
		player:Kick(message)
	else
		print("Do not trust them...")
	end
end)

So I tried reworking this to make turn it into what I am trying to do:

local miko = {
	WarEspmon19 = true,
	WarUmbmon12 = true,
}

game.Players.PlayerAdded:Connect(function(player)
	if miko[player.Name] then
		playerJoin.Team = "Miko"
	else
	end
end)

However this does not seem to be working. Any ideas on how to make it work?

1 answer

✓ Accepted answer

The Player.Team operator requires you to use a Team object that can be found in the Teams class. This updated script should work. If not, DM me on discord @ MachoPiggies#3484.

local miko = {
    WarEspmon19 = true,
    WarUmbmon12 = true,
}

game.Players.PlayerAdded:Connect(function(player)
    if miko[player.Name] then
        player.Team = game.Teams:FindFirstChild("Miko")
    else
        print("owo")
    end
end)

1 comment

0

It worked! Thank you

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