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

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

Asked by 4 years ago

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

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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)

0
It worked! Thank you WarUmbmon12 2 — 4y
Ad

Answer this question