This script should globally call maps however I recieve an error when running it.
function _G.GetMaps() -- can now be used in any other server script local maps = game.ServerStorage.Maps:GetChildren() for _,v in pairs(maps)do local randommap = math.random(v) x=randommap:Clone() x.Parent = game.Workspace local m = Instance.new("Message", workspace) m.Text = (x.Name.. " is the current map!" ) wait(3) end end
any and all help appreciated
Error I recieve when running the script
23:35:48.089 - ServerScriptService.GetMaps global function:5: bad argument #1 to 'random' (number expected, got Object)
I presume you want a random map to be chosen.
function _G.GetMaps() local maps = game.ServerStorage.Maps:GetChildren() local randomSelect = math.random(1,#maps) local randomMap = maps[randomSelect] local x = randomMap:Clone() x.Parent = workspace local m = Instance.new('Message',workspace) m.Text = (x.Name..' is the current map!') wait(3) -- game:GetService('Debris'):AddItem(m,3), will delete the message too. end