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 leaderstats = Instance.new("IntValue")
- leaderstats.Name = "leaderstats"
- leaderstats.Parent = player
- local Cash = Instance.new("IntValue", leaderstats)
- Cash.Name = "cash"
- Cash.Value = 0
- Cash.Parent = leaderstats
- local Abbonees = Instance.new("IntValue",leaderstats)
- Abbonees.Name = "abbonees"
- Abbonees.Value = 0
- Abbonees.Parent = leaderstats
- local Videos = Instance.new("IntValue",leaderstats)
- Videos.Name = "videos"
- Videos.Value = 0
- Videos.Parent = leaderstats
- dsc:SetAsync(player.UserId + "Cash", Cash.Value) -- saving the value
- Cash.Changed:connect(function() -- if the value changes
- dsc:SetAsync(player.UserId + "Cash", Cash.Value) -- saves the value
- dsa:SetAsync(player.UserId + "Abbos", Abbonees.Value) -- saving the value
- Abbonees.Changed:connect(function() -- if the value changes
- dsa:SetAsync(player.UserId + "Abbos", Abbonees.Value)
- dsv:SetAsync(player.UserId + "Vids", Videos.Value) -- saving the value
- Videos.Changed:connect(function() -- if the value changes
- dsv:SetAsync(player.UserId + "Vids", Videos.Value)
- end)
- end)
- end)
- 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
- end)
Add Comment
Please, Sign In to add comment