I'm making this simulator game, I was finishing up my shop until I ran into this problem, how do I save leaderstat values and tools that I've bought? It saves the leaderstat value "Chemicals" in studios and in an actual server, but I want to save the tools that i bought as well. How do I do that?
Here's my script:
local DS = game:GetService("DataStoreService"):GetDataStore("MyLovelyGame06992299")
game.Players.PlayerAdded:connect(function(player)
local key = "key-"..player.userId
local leaderstats = Instance.new("Folder",player)
leaderstats.Name = "leaderstats"
local Chemicals = Instance.new("IntValue",leaderstats)
Chemicals.Name = "Chemicals" --Value that I try to save
local save = DS:GetAsync(key)
if save then
Chemicals.Value = save[1]
else
local load = {Chemicals.Value}
DS:SetAsync(key,load)
end
while wait(1) do
Chemicals.Value = Chemicals.Value + 15
end
end)
game.Players.PlayerRemoving:connect(function(player)
local key = "key-"..player.userId
local load = {player.leaderstats:FindFirstChild("Chemicals").Value}
print("Doing")
DS:SetAsync(key,load)
end)
Any help would be appreciated :)

1 comment
connect is deprecated, use Connect