Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Thanks for using this script
- --This script is made by Joriangames/Problox Studio Scripts
- --Want to know how to use this? Watch my tutorial: https://youtu.be/4paRumpzt0g
- local DSS = game:GetService("DataStoreService")
- local myDataStore = DSS:GetDataStore("myDataStore")
- game.Players.PlayerAdded:Connect(function(plr)
- local lead = Instance.new("Folder")
- lead.Name = "leaderstats"
- lead.Parent = plr
- local Cash = Instance.new("IntValue")
- Cash.Name = "Cash"
- Cash.Parent = lead
- local data
- local succ, err = pcall(function()
- data = myDataStore:GetAsync(plr.UserId.."_cash", plr.leaderstats.Cash.Value)
- end)
- if succ then
- Cash.Value = data
- --set the data equal to the current cash
- print("Succesfully got the data!")
- end
- end)
- game.Players.PlayerRemoving:Connect(function(plr)
- local data = plr.leaderstats.Cash.Value
- local succ, err = pcall(function()
- myDataStore:SetAsync(plr.UserId.."_cash", plr.leaderstats.Cash.Value)
- end)
- if succ then
- print("Succesfully saved the data!")
- else
- print("There was an error while saving data")
- warn(err)
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement