hi, i made a save currency script but and it worked, but after a few hours it didn't work anymore. i feel it may be because i got some of the currency on studio but if you know a definite reason to why this may have happened please tell me.
here is the script if it helps:
local DataStore = game:GetService("DataStoreService")
local ds = DataStore:GetDataStore("CashSaveSystem")
game.Players.PlayerAdded:connect(function(player)
local leader = Instance.new("Folder",player)
leader.Name = "leaderstats"
local PowerBlocks = Instance.new("IntValue",leader)
PowerBlocks.Name = "PowerBlocks"
PowerBlocks.Value = ds:GetAsync(player.UserId) or 0
ds:SetAsync(player.UserId, PowerBlocks.Value)
PowerBlocks.Changed:connect(function()
ds:SetAsync(player.UserId, PowerBlocks.Value)
end)
end)
game.Players.PlayerRemoving:connect(function(player)
ds:SetAsync(player.UserId, player.leaderstats.PowerBlocks.Value)
end)
thanks in advance from poopypigeon245

1 comment
update: ive noticed that it'll load your currency if you rejoin about two times so take this into consideration while writing an answer