Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local DataStore = game:GetService("DataStoreService") -- getting the data store
- local dsc = DataStore:GetDataStore("CashSaveSystem") -- making a new datastore
- local dsa = DataStore:GetDataStore("AbbosSaveSystem")
- local dsv = DataStore:GetDataStore("VidsSaveSystem")
- game.Players.PlayerAdded:Connect(function(player)-- function when you join
- local successcash, cash = pcall(function()
- return dsc:GetAsync(player.UserId .. "Cash")
- end)
- if successcash then
- print("cash sucseeded")
- end
- local successabbos, abbonees = pcall(function()
- return dsc:GetAsync(player.UserId .. "Abbos")
- end)
- if successabbos then
- print("abbos sucseeded")
- end
- local successvids, videos = pcall(function()
- return dsc:GetAsync(player.UserId .. "Vids")
- end)
- if successvids then
- print("vids sucseeded")
- end
- local leaderstats = Instance.new("IntValue")
- leaderstats.Name = "leaderstats"
- leaderstats.Parent = player
- local cash = Instance.new("IntValue")
- cash.Name = "cash"
- cash.Value = -1
- if successcash then
- cash.Value = successcash
- else
- warn(cash)
- end
- cash.Parent = leaderstats
- local abbonees = Instance.new("IntValue")
- abbonees.Name = "abbonees"
- abbonees.Value = -1
- if successabbos then
- abbonees.Value = abbonees
- else
- warn(abbonees)
- end
- abbonees.Parent = leaderstats
- local videos = Instance.new("IntValue")
- videos.Name = "videos"
- videos.Value = -1
- if successcash then
- videos.Value = videos
- else
- warn(videos)
- end
- videos.Parent = leaderstats
- end)
- game.Players.PlayerRemoving:Connect(function(player) -- when you leave
- dsc:SetAsync(player.UserId.. "Cash", player.leaderstats.cash.Value) -- saving the value
- dsa:SetAsync(player.UserId.. "Abbos", player.leaderstats.abbonees.Value) -- saving the value
- dsv:SetAsync(player.UserId.. "Vids", player.leaderstats.videos.Value) -- saving the value
- print("Cash:".. player.leaderstats.cash.Value)
- print("Abbos:".. player.leaderstats.abbonees.Value)
- print("vids:".. player.leaderstats.videos.Value)
- print(player.UserId.. "Cash")
- end)
Advertisement
Add Comment
Please, Sign In to add comment