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

How could I make a fully functional choosemap script, without using freemodels?

Hi, I'm trying to make a game like lava escape. I'm sure you all from years ago may know it. So, I'm trying to make a map choosing system which chooses a random map. I'm using a test script to see what it'd choose by name. NOTE: I'm not good at choosing map scripts aswell as math.random. So, um, heres my script. I'd be happy to accept your answers once done.

Workspace Script

local rps = game:GetService("ReplicatedStorage")
local maps = rps.gms --Gms is the maps, in rps.


	
while wait(3) do	
	for i,v in pairs(maps:GetChildren()) do
	local mapchosen =	math.random(maps) --Error Occurs at  this line.
	print(mapchosen)
end
end

--Output Message: 18:51:03.367 - Workspace.Script:8: bad argument #1 to 'random' (number expected, got Object)

1 answer

You can select a random variable from a table like so

local rTabValue = tab[math.random(#tab)]

# takes the number of variables in a table and math.random(#tab) will do the same as math.random(1,#tab).

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