Hello, I am working on a game that uses a data store script to save the amount of currency you have but for some reason it does not work.
local DataStore = game:GetService("DataStoreService")
local ds = DataStore:GetDataStore("ToadsSaver")
game.Players.PlayerAdded:connect(function(player)
local leader = Instance.new("Folder",player)
leader.Name = "leaderstats"
local Toads = Instance.new("IntValue",leader)
Toads.Name = "Toads"
Toads.Value = ds:GetAsync(player.UserId) or 0
ds:SetAsync(player.UserId, Toads.Value)
Toads.Changed:connect(function()
ds:SetAsync(player.UserId, Toads.Value
end)
end)
game.Players.PlayerRemoving:connect(function(player)
ds.SetAsync(player.UserId, player.leaderstats.Toads.Value)
end)
