I am trying to make a minigames game and this is a function I made to clone a random map into workspace but I get this error: Workspace.Main:3: bad argument #2 to 'random' (interval is empty)
function GetMap() local MapsFolder = game.ReplicatedStorage.Maps:GetChildren() local SelectMap = math.random(1, #MapsFolder) local SelectedMap = MapsFolder[SelectMap]:Clone() SelectedMap.Parent = game.Workspace SelectedMap.Name = "Map" end
It looks like your MapsFolder is empty.
When you try to use GetChildren()
and there is no children, it will return nil.
So when you try to use #MapsFolder
, it will also be nil. Which causes an error in math.random()
Let me know if you have any other questions!