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

How do I make a script that picks 3 teams with no team gui?

Asked by 10 years ago

Like im murder mystery, Possesion the way it picks Innocent,Sherrif,Murder -In murder myster- Ghost,Human -In possesion-

1 answer

Log in to vote
0
Answered by
jobro13 980 Moderation Voter
10 years ago

You can hide the team gui (leaderboard) with:

game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, false)

We need to assign 3 teams: Innocent, Sherrif, Murder. We know that:

  • You can only be in one team
  • Sherrif and Murder team both have only one person

So, the best approach is to assign Sherrif and Murderer first and then assign everyone else to Innocent.

function ReOrganizeTeams()
    if #game.Players:GetPlayers() <= 3 then
        print("Not enough players")
        return 
    end 
    local function random_index(tab)
        return math.random(1, #tab)
    end

    local players = game.Players:GetPlayers()

    local murderer = random_index(players)
    players[murderer].TeamColor = BrickColor.Red() -- The murder team color
    --remove the murderer from the table
    table.remove(players, murderer) 

    local sherrif = random_index(players)
    players[sherrif].TeamColor = BrickColor.Blue() -- sheriff team color
-- also remove the sheriff
    table.remove(players, sherrif)

    for _, player in pairs(players) do
        player.TeamColor = BrickColor.Green() -- for everyone else assign innocent team color
    end
0
So I put them into local scripts and Make a team gui with the 3 teams and then it will work? Mobslayer00 0 — 10y
0
This should run on the server as it otherwise would run that code for every player. You can create the team guis by checking the players' team colors -> blue = sherif, red = murderer, green = innocent. jobro13 980 — 10y
Ad

Answer this question