So I'm trying to make a basic map cache that after it is selected, it would take the last map from the cache and put it back in the pool and then take the selected map and put it in the cache. However, my method doesn't take the last map from the cache, so the game works until it runs out of maps. Here's the script:
local currentMap = MapsToChoose[math.random(#MapsToChoose)] local workspace_map = game.ServerStorage.Maps[currentMap]:Clone() local outside_map = game.ServerStorage.Maps[currentMap] local outcache = game.ServerStorage.OutMaps workspace_map.Parent = game.Workspace.CurrentMap outcache:GetChildren().Parent = game.ServerStorage.Maps outside_map.Parent = game.ServerStorage.OutMaps
local currentMap = MapsToChoose[math.random(#MapsToChoose)] local workspace_map = game.ServerStorage.Maps[currentMap]:Clone() local outside_map = game.ServerStorage.Maps[currentMap] local outcache = game.ServerStorage.OutMaps workspace_map.Parent = game.Workspace.CurrentMap for i,v do in pairs(outcache:GetChildren()) do v.Parent = game.ServerStorage.Maps outside_map.Parent = game.ServerStorage.OutMaps end