Hello, how could I just get the maps from the folder instead of getting the stuff inside of the map folder? I’ve tried removing the get children although the output shows table expected got instance.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MapsList = ReplicatedStorage:FindFirstChild("Maps"):GetChildren()
local ChosenMaps = MapsList[math.random(2, #MapsList)]:GetChildren()
local Voting = script.Parent
local Maps = Voting:FindFirstChild("Maps")
local Template = script:FindFirstChild("Template")
function CreateFrame(Map, Image)
local Frame = Template:Clone()
Frame.Name = Map
Frame.Title.Text = Map
Frame.Image = Image
Frame.Parent = Maps
return Frame
end
function AddMaps(Data)
for i, v in ipairs(Data) do
local Frame = CreateFrame(v.Name, v.Image.Value)
end
end
AddMaps(ChosenMaps)
local ChosenMaps = MapsList[math.random(2, #MapsList)]:GetChildren()
Instead of this, replace it with this :
local ChosenMaps = MapsList[math.random(1, #MapsList:GetChildren())]
Since you want to choose a random map out of #YourMaps, you want to get a random number between 1[normal, classic] to the number of maps you have inside of that folder
local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
local MapsList = ReplicatedStorage:FindFirstChild(“Maps”)
local ChosenMaps = MapsList[math.random(1, #MapsList:GetChildren())]
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MapsList = ReplicatedStorage:FindFirstChild("Maps")
local ChosenMap = MapsList:GetChildren()[math.random(1, #MapsList:GetChildren())]
print(ChosenMap.Name)
What happend here
After we got the maps folder, we actually need to get the map by getting a random map out of all the existent maps.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MapsList = ReplicatedStorage:FindFirstChild("Maps")
local ChosenMap = MapsList:GetChildren()[math.random(1, #MapsList:GetChildren())]
--print(ChosenMap.Name)
function AddMaps(Data)
for i, v in ipairs(Data:GetChildren()) do
--your code
end
end
AddMaps(MapsList:FindFirstChild(ChosenMap.Name))
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MapsList = ReplicatedStorage:FindFirstChild("Maps")
local ChosenMap = MapsList:GetChildren()[math.random(1, #MapsList:GetChildren())]
--print(ChosenMap.Name)
local Voting = script.Parent
local Maps = Voting:FindFirstChild("Maps")
local Template = script:FindFirstChild("Template")
function CreateFrame(Map, Image)
local Frame = Template:Clone()
Frame.Name = Map
Frame.Title.Text = Map
Frame.Image = Image
Frame.Parent = Maps
return Frame
end
function AddMaps(Data)
for i, v in ipairs(Data:GetChildren()) do
local Frame = CreateFrame(v.Name, v.Image.Value)
end
end
AddMaps(MapsList:FindFirstChild(ChosenMap.Name))