Hello I am new to script so I need help to help me I would like to make a system which makes in a folder you had Map1 and Map2 here is what I am trying to do :
sorry i am bad for speak my problem
local mapmode = script.Number.Value
wait(1)
print("Value : "..mapmode) -- mapmode = 1
wait(5)
local mapload = false
wait(1)
if mapload == false then
mapload = true
map = math.random()
for i,v in pairs(game.ReplicatedStorage.map.Map..mapmode:GetChildren()) do -- error are here
if i == map then
local loadmap = v:clone()
print("Map Select Are "..v.Name)
loadmap.Parent = game.Workspace
end
end
end
I try to do with the mapmode which is equal to 1 that in the map folder its chosen Map1 and when I but 2 in the mapmode its chosen Map2 but its telling me error
I try several ways but I canāt find how to do it: /
One thing I think you may be missing is the debounce variable āmaploadā. At the top, you check if itās false, and if it is, you set it to true; but at the end of that if statement, thereās no thing that sets the value back to false.
EDIT:
Looking back at the code, you have the code:
for i,v in pairs(game.ReplicatedStorage.map.Map .. mapmode:GetChildren()) do
Basically, itās taking the map.Map object, without the number on the end, and itās adding a string (mapmode) to that, which canāt be done. The fix to this is
for i,v in pairs(game.ReplicatedStorage.map["Map"..mapmode]:GetChildren()) do
And Iāll explain why. Itās using "Map"..mapmode as the name of the child itās looking for inside of game.ReplicatedStorage.map. This should solve your problem.