local rs = game:GetService("ReplicatedStorage") local DataStoreService = game:GetService("DataStoreService") local DataStore = DataStoreService:GetDataStore("AdminDatastore") game:IsLoaded(function() DataStore:GetAsync() end) game:BindToClose(function() wait(10) for i,v in pairs(game.ReplicatedStorage.AdminEvents.Banned:GetChildren()) do DataStore:SetAsync(v.Name,v.Value) end end)
So I'm experimenting with saving string values names and values when the server shuts down. I need it to set them on the game:IsLoaded part, I'm not sure what to add. Could someone help me if theres anything I need to add on the bindtoclose part, and what to add on the isloaded part to get it to work correct?
Alright. So when you do the loop each time it saves the value to a key. If you want it to get every single banned person you're going to have to save it in one value and split it once the game is loaded.
local rs = game:GetService("ReplicatedStorage") local DataStoreService = game:GetService("DataStoreService") local DataStore = DataStoreService:GetDataStore("AdminDatastore") repeat wait() until game.ReplicatedStorage.AdminEvents.Banned local one = DataStore:GetAsync("bans") local two = string.split(one, "|") for i,v in pairs(two) do local three = Instance.new("StringValue") local four = string.split(v, ",") three.Name = four[1] three.Value = four[2] three.Parent = game.ReplicatedStorage.AdminEvents.Banned end game:BindToClose(function() local update for i,v in pairs(game.ReplicatedStorage.AdminEvents.Banned:GetChildren()) do if update == nil then update = v.Name..","..v.Value else update = update.."|"..v.Name..","..v.Value end end DataStore:SetAsync("bans",update) end)
Tested! It works now.