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

Gamemode picker not working?

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!

1 comment

0

Updated my answer.

1 answer

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

2 comments

0

There was an extra end because I took out part of the script for my question and forgot to take out the end.

0

@jimborimbo, Well go ahead and add the end, to see if it works. Let me know if it errors!

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