Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- variables
- local dsService = game:GetService("DataStoreService")
- local ds = dsService:GetDataStore("leader")
- -- main code
- game.Players.PlayerAdded:Connect(function(player)
- local folder = Instance.new("Folder", player)
- folder.Name = "leaderstats"
- local cash = Instance.new("IntValue", folder)
- cash.Name = "Cash"
- cash.Value = ds:GetAsync(player.UserId) or 0
- -- auto saving script
- cash.Changed:Connect(function()
- ds:SetAsync(player.UserId, cash.Value)
- end)
- end)
Add Comment
Please, Sign In to add comment