The dataStore script shown below does not error nor does it save a players data. (I’ve tried in game) Thanks
local ds = game:GetService("DataStoreService"):GetDataStore("Upgrade_saving__47859bv9nwvg")
local upgrade_folder = game.ServerStorage.Upgrades -- Change this to where you're storing the tools
game.Players.PlayerAdded:Connect(function(plr)
local item_fold = Instance.new("Folder")
item_fold.Name = "upgrades"
item_fold.Parent = plr
for _, v in pairs (upgrade_folder:GetChildren()) do -- Creates a new bool value for every tool in the folder
local upgrade = Instance.new("NumberValue")
upgrade.Name = v.Name -- Setting the bool value name to the weapon's name
upgrade.Parent = item_fold
upgrade.Value = ds:GetAsync(v.Name .. plr.UserId) or 1
if ds:GetAsync(v.Name .. plr.UserId) ~= nil then -- Checking to see if the player has ever played the game
local succ, msg = pcall(function()
upgrade.Value = ds:GetAsync(v.Name.. plr.UserId) -- setting the value to the saved data
end)
if not succ then
warn("Problem with getting and setting data "..msg)
end
end
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
local succ, msg = pcall(function()
for _, v in pairs (plr.items:GetChildren()) do
ds:SetAsync(v.Name .. plr.UserId, v.Value) -- Saving the values
end
end)
if not succ then
warn("Problem with saving data ".. msg)
end
end)