I am trying to save objects the player has built but I get the error in the title
script in ServerScriptService:
local Data = game:GetService('DataStoreService'):GetDataStore('Data0') local prefix = 'user_' game.Players.PlayerAdded:Connect(function(plr) -- Define variables local uniquekey = 'id-'..plr.UserId local Storage = Instance.new("Folder") Storage.Parent = plr Storage.Name = "Storage" local Objects = Storage:GetChildren() print("Loading boat...") local function Load() local plrData = Data:GetAsync(prefix .. tostring(plr.UserId)) if plrData then Storage:GetChildren(Objects) Data:SetAsync(uniquekey, Storage) print("Loaded :D") else print("Data wasn't loaded.") Data:SetAsync(prefix .. tostring(plr.UserId), { print("Trying again."), Storage:GetChildren(Objects), Data:SetAsync(uniquekey, Storage), print("Loaded") }) end end Load() end) game.Players.PlayerRemoving:Connect(function(plr) print("Saving data for",plr.Name) Data:GetAsync(prefix .. tostring(plr.UserId)) end)
The problem is at line 22.