create a coin system where, if the player touches a coin, he gets money so I created a system to save your amount of money, but there was a problem: the only thing saved is the value of the money, that is, if a player takes a coin in a game, leaves the game and enters again, the coin will be there . my doubt is: is there any way for me to save the coins he took so that, the next time he enters the game, they don't reappear? i created this script to save player data:
local data = game:GetService("DataStoreService"):GetDataStore("Moneyy")
game.Players.PlayerAdded:Connect(function(player)
local money = player:WaitForChild("leaderstats"):WaitForChild("Money")
local datas = data:GetAsync(player.UserId)
if datas ~= nil then
money.Value = datas
end
end)
game.Players.PlayerRemoving:Connect(function(player)
data:SetAsync(player.UserId,player.leaderstats.Money.Value)
end)
