Lets say you had a folder named “Mapholder” and every few rounds, a new map goes into that folder with the other being destroyed. If the map or maps had a certain name, for example lets name this map “Factory.”
If the script found anything named Factory, it would make the clocktime 0.
If the script didnt find anything named factory, it’ll make the clocktime 14 or do something else.
It would only do something different if it found certain names, for example if I had 3 maps that I wanted to have this effect, lets name them “Factory”, “Mansion”, and “Shelter”. If the script detected any name in that folder named Factory or Shelter, It’d go dark.
But if it were not to detect anything of the names Factory and Shelter, the clocktime would go day.
What I meant to say was, for example if any amount of maps are in the folder, itll make the clocktime 0, but if they aren’t in the folder, itll make it day. I know how to make the day/night part, but not the part where it will detect if the any amount of maps you can add are in the folder.
I am not too sure what you are looking for here but you can use a FindFirstChild method
Example:
if game.ReplicatedStorage.Maps:FindFirstChild("test1") ~= nil then
if game.ReplicatedStorage.Maps["test1"].ClassName == "Model" then
print("Map folder contains test1")
else
print("Map folder does not contain test1")
end
else
print("Map folder does not contain test1")
end
What I meant to say was, for example if any amount of maps are in the folder, itll make the clocktime 0, but if they aren’t in the folder, itll make it day. I know how to make the day/night part, but not the part where it will detect if the any amount of maps you can add are in the folder.
What I meant to say was, for example if any amount of maps are in the folder, itll make the clocktime 0, but if they aren’t in the folder, itll make it day.
Are you looking for to see if a table has or no values? the code i showed down checks if the table has any values, if not it just prints “empty table”.
if #maps > 0 then
print("there are values inside")
else
print("empty table")
end
local maps = {"Test1", "Test2", "Test3"}
local MapsFolder = game.ReplicatedStorage.Maps
local function Contains(str)
if MapsFolder:FindFirstChild(str) ~= nil then
if MapsFolder[str].ClassName == "Model" then
return true
else
return false
end
else
return false
end
end
local HasMap = false
for _,m in ipairs(maps) do
if Contains(m) then
HasMap = true
break
end
end
if HasMap then
--Contains a map inside the map table
else
--Does not Contain a map inside the map table
end
Lets say you had a folder named “Mapholder” and every few rounds, a new map goes into that folder with the other being destroyed. If the map or maps had a certain name, for example lets name this map “Factory.”
If the script found anything named Factory, it would make the clocktime 0.
If the script didnt find anything named factory, it’ll make the clocktime 14 or do something else.
It would only do something different if it found certain names, for example if I had 3 maps that I wanted to have this effect, lets name them “Factory”, “Mansion”, and “Shelter”. If the script detected any name in that folder named Factory or Shelter, It’d go dark.
But if it were not to detect anything of the names Factory and Shelter, the clocktime would go day.
local folder = workspace.Mapholder
local maps = {"Factory", "Mansion", "Shelter"}
for i, map in pairs(maps) do
if folder:FindFirstChild(map) then -- checks if folder, "Mapholder", has any of the maps in the table
print("dark")
else
print("clear")
end
end
OR
local folder = workspace.Mapholder
local maps = {"Factory", "Mansion", "Shelter"}
for i, map in pairs(maps) do
for n, child in pairs(folder:GetChildren()) do
if child.Name == map then -- checks if any of the children of the folder has the names of the maps in the table
print("dark")
else
print("clear")
end
end
end