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

how do you use math.random with tables?

I making a spoof game and I ran into a snag. It's giving me this error " Workspace.Script:3: bad argument #2 to 'random' (interval is empty)"

local maps = game.ReplicatedStorage.map:GetChildren()

map = maps[math.random(#maps)]:Clone -- this is the erroring part
map.Parent = game.Workspace

1 answer

✓ Accepted answer

You were missing the parenthesis for the Clone variable, here is a fix for that.

local maps = game.ReplicatedStorage.map:GetChildren()

map = maps[math.random(1, #maps)]:Clone() -- this is the erroring part
map.Parent = game.Workspace

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