Hello, I have recently put a "coin system" into my game. This system will save your coins when you leave the game. I am not that advanced at coding so I am following the youtuber "AlvinBlox" for a tutorial. The entire script seems to be working except one tiny part. Here is said script:
game.Players.PlayerRemoving:Connect(function(player)
local ID = CurrencyName..":"..player.UserId
DataStore:SetAsync(ID.player.leaderstats.CurrencyName.Value)
print("Data Saved")
end)
When I leave the game, it says that the player is nil. I suspect that it is because the player is not in the game anymore so the server can't save the progress (I am not sure though). I am simply looking for a fix for this glitch.

1 comment
"Currency name is not a valid member of folder" this error appeared