Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

can somebody help me with this problem I have with a datastore?

Asked by 3 years ago

so I made a datastore script to save the value "WhiteEggs" but for some reason it doesn't work, it was working before but it doesn't now for some reason


local DataStoreService = game:GetService("DataStoreService") local ItemSaving = DataStoreService:GetDataStore("ItemSaving") game.Players.PlayerAdded:Connect(function(player) local DataStoreValues = Instance.new("Folder") DataStoreValues.Name = "DataStoreValues" DataStoreValues.Parent = player local WhiteEggs = Instance.new("IntValue") WhiteEggs.Name = "WhiteEggs" WhiteEggs.Parent = DataStoreValues local Data local success, errormessage = pcall(function() Data = ItemSaving:GetAsync(player.UserId.."-WhiteEggs") end) if success then WhiteEggs.Value = Data else print("Data Loading Error") warn(errormessage) end end) game.Players.PlayerRemoving:Connect(function(player) local success,errormessage = pcall(function() ItemSaving:SetAsync(player.UserId.."-WhiteEggs",player.DataStoreValues.WhiteEggs.Value) end) if success then print("Data Saved") else print("Data Did not Save!") warn(errormessage) end end)

Answer this question