RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"my model names are "Expand#1" and "Expand#2""
-- server script local DataStoreService = game:GetService("DataStoreService") local myDataStore = DataStoreService:GetDataStore("MyDataStore") local function saveModels() local modelFolder = game.Workspace.ModelFolder local modelNames = {"Expand#1", "Expand#2"} -- Save the model names local success, error = pcall(function() myDataStore:SetAsync("ModelNames", modelNames) end) if success then print("Models saved successfully!") else print("Failed to save models: " .. error) end end local function loadModels() local success, modelNames = pcall(function() return myDataStore:GetAsync("ModelNames") end) if success then local modelFolder = game.Workspace.ModelFolder modelFolder:ClearAllChildren() -- Remove any existing models -- Recreate each model using its saved name for i, modelName in ipairs(modelNames) do local newModel = Instance.new("Model") newModel.Name = modelName newModel.Parent = modelFolder end print("Models loaded successfully!") else print("Failed to load models: " .. modelNames) end end saveModels() wait(5) loadModels()