Okay so I am making a minigame kind of game and instead of it picking a random map it picks a random map. This is the only thing wrong with the game. Please help me.
SCRIPT:
I have more if needed.
Okay so I am making a minigame kind of game and instead of it picking a random map it picks a random map. This is the only thing wrong with the game. Please help me.
SCRIPT:
I have more if needed.
I didn't check the script, but i'll try giving some info so you can implement it:
Array is a class that holds multiple value, made with curly brackets.
Example:
local maps = {workspace.Maps.Map1,workspace.Maps.Map2}
--the value maps is an array holding two values, Map1 and Map2
You can also create an array containing all children of an instance with :GetChildren(). Example:
local maps = workspace.Maps:GetChildren()
--maps is a value holding all objects inside it
Now that you got the array of maps you have, you must randomly select the one that will be used, which can be done with math.random(min,max), where min should be 1 and max, the number of maps you made. Note that by typing #maps or table.getn(maps) you will get the number of values held inside that array, so you can make it like this:
local randommap = math.random(1,#maps).
Now you just need to get the specific value from the array using randommap, like this:
local map = maps[randommap]
Just beware that :GetChildren() will get everything that is parented to the instance, so you'll have to let just the maps inside that folder.
Also, math.random isn't always so random, so typing math.randomseed(tick()) before your code might help, althought it doesn't seem to change much for me. Random.new() works too, but I didn't check it yet.
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
I doubt this is your code, considering it literally has independently-made
:WaitForChild()and:FindFirstChild()functions.