I have a gamemode picker and it picks a number instead of a gamemode.
while true do local gamemodes = {"Team Deathmatch", "Domination", "Capture The Flag"} game.Workspace.MessageHolder.Text = "2 Players are needed to start a round." wait(0) if game.Players.NumPlayers >= 2 then game.Workspace.MessageHolder.Text = "Intermission" wait(2) local gamemode = math.random(1, #gamemodes) -- it picks a number instead of a gamemode wait(2) game.Workspace.MessageHolder.Text = "The Selected Game Mode is " ..gamemode.. " !" -- this displays the picked number when I want it to show the picked gamemode wait(2) game.Workspace.MessageHolder.Text = "Starting..." end end end
Help me please!
Your problem is on line 8. You're telling the script to pick a number between 1, and the length of the table 'gamemodes'. To have it pick a value from the table, it would be local gamemode = gamemodes[math.random(1, #gamemodes)]
You also put an extra end, which was unnecessary. Here is your full script:
while true do local gamemodes = {"Team Deathmatch", "Domination", "Capture The Flag"} game.Workspace.MessageHolder.Text = "2 Players are needed to start a round." wait(0) if game.Players.NumPlayers >= 2 then game.Workspace.MessageHolder.Text = "Intermission" wait(2) local gamemode = gamemodes[math.random(1, #gamemodes)] --It doesn't need to be local wait(2) game.Workspace.MessageHolder.Text = "The Selected Game Mode is " ..gamemode.. " !" game.Workspace.MessageHolder.Text = "Starting..." end end