So I made a Data Store that saves both tools and money, but for some reason it doesn't work. The output doesn't show any errors so I got a dead end.
The Code:
local DSS = game:GetService("DataStoreService") local MoneySave = DSS:GetDataStore("General", "Money") local GearSave = DSS:GetDataStore("General", "Gear") game.Players.PlayerAdded:Connect(function(player) local key = "player-".. player.UserId pcall(function() local money = MoneySave:GetAsync(key) local gear = GearSave:GetAsync(key) if money then player:WaitForChild("leaderstats"):WaitForChild("Money").Value = MoneySave[1] else local MoneyForSaving = {player:WaitForChild("leaderstats"):WaitForChild("Money").Value} MoneySave:GetAsync(key, MoneyForSaving) end if gear then for _,v in pairs(gear) do local gears = game:GetService("ReplicatedStorage"):FindFirstChild(v) if gears then gears:Clone().Parent = player.Backpack if not player.StarterGear:FindFirstChild(v) then gears:Clone().Parent = player.StarterGear end end end end end) end) game.Players.PlayerRemoving:Connect(function(player) local key = "player-".. player.UserId pcall(function() local MoneyToSave = {player:WaitForChild("leaderstats"):WaitForChild("Money").Value} local GearToSave = {} for _,v in pairs(player.Backpack) do table.insert(GearToSave, v.Name) end end) end)
And please, tell me what I did wrong
You're getting the data store, but I don't see you setting it anywhere. Look into SetAsync and UpdateAsync.