Advertisement
Sungmingamerpro13

My New Wins and Rounds Lobby + Roles

Nov 13th, 2024
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 3.39 KB | None | 0 0
  1. local DatastoreService = game:GetService("DataStoreService")
  2. local TeleportService = game:GetService("TeleportService")
  3.  
  4. local VIP = 64418164
  5.  
  6. local LivesSave = DatastoreService:GetDataStore("Lives")
  7.  
  8. game.Players.PlayerAdded:Connect(function(player)
  9.     local previousData = LivesSave:GetAsync(player.UserId) -- Returns a number value.
  10.  
  11.     local Lives
  12.  
  13.     if previousData ~= nil then
  14.         Lives = previousData
  15.     else
  16.         Lives = 0
  17.         LivesSave:SetAsync(player.UserId, 0)
  18.     end
  19.  
  20.     local LivesValue = Instance.new("IntValue", player)
  21.     LivesValue.Name = "Lives"
  22.     LivesValue.Value = Lives
  23.  
  24. end)
  25.  
  26. game:BindToClose(function() -- Runs whenver the server is about to shut down/stop.
  27.     print("STOPPED!")
  28.  
  29.     for i,player in pairs(game.Players:GetPlayers()) do
  30.         local value = player.Lives.Value
  31.         LivesSave:SetAsync(player.UserId, value)
  32.         print("Saved data for "..player.Name)
  33.     end
  34. end)
  35.  
  36. game.Players.PlayerRemoving:Connect(function(player)
  37.     local value = player.Lives.Value
  38.  
  39.     if value ~= nil then
  40.         print("Found data to save for "..player.Name.."!")
  41.         LivesSave:SetAsync(player.UserId, value)
  42.         print("Saved data for "..player.Name)
  43.     else
  44.         print("Did not manage to find data to save for "..player.Name.."!")
  45.     end
  46. end)
  47.  
  48. local CoinsSave = DatastoreService:GetDataStore("Coins")
  49.  
  50. game.Players.PlayerAdded:Connect(function(player)
  51.     local previousData = CoinsSave:GetAsync(player.UserId) -- Returns a number value.
  52.  
  53.     local Coins
  54.  
  55.     if previousData ~= nil then
  56.         Coins = previousData
  57.     else
  58.         Coins = 0
  59.         CoinsSave:SetAsync(player.UserId, 0)
  60.     end
  61.  
  62.     local coinsValue = Instance.new("IntValue", player)
  63.     coinsValue.Name = "Coins"
  64.     coinsValue.Value = Coins
  65.  
  66.     local val1 = Instance.new("StringValue",player)
  67.     val1.Name = 'GotPet'
  68.     val1.Value = ''
  69.  
  70.     local val2 = Instance.new("StringValue",player)
  71.     val2.Name = 'OpenValue'
  72.     val2.Value = ''
  73.    
  74.     if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, VIP) then
  75.         player.Coins.Value = player.Coins.Value * 2
  76.     end
  77. end)
  78.  
  79. game:BindToClose(function() -- Runs whenver the server is about to shut down/stop.
  80.     print("STOPPED!")
  81.  
  82.     for i,player in pairs(game.Players:GetPlayers()) do
  83.         local value = player.Coins.Value
  84.         CoinsSave:SetAsync(player.UserId, value)
  85.         print("Saved data for "..player.Name)
  86.     end
  87. end)
  88.  
  89. game.Players.PlayerRemoving:Connect(function(player)
  90.     local value = player.Coins.Value
  91.  
  92.     if value ~= nil then
  93.         print("Found data to save for "..player.Name.."!")
  94.         CoinsSave:SetAsync(player.UserId, value)
  95.         print("Saved data for "..player.Name)
  96.     else
  97.         print("Did not manage to find data to save for "..player.Name.."!")
  98.     end
  99. end)
  100.  
  101. local SaveRoles = game:GetService("DataStoreService"):GetDataStore("Role")
  102.  
  103. game.Players.PlayerAdded:Connect(function(player)
  104.  
  105.     local  Role = Instance.new("StringValue", player)
  106.     Role.Name = "Role"
  107.     Role.Value = player.Role.Value
  108.  
  109. end)
  110.  
  111. game:BindToClose(function()
  112.     for i,player in pairs(game.Players:GetPlayers()) do
  113.         local value = player.Role.Value
  114.         SaveRoles:SetAsync(player.UserId, value)
  115.         print("Saved data for "..player.Name)
  116.     end
  117. end)
  118.  
  119. game.Players.PlayerRemoving:Connect(function(player)
  120.     local value = player.Role.Value
  121.  
  122.     if value ~= nil then
  123.         print("Found data to save for "..player.Name.."!")
  124.         SaveRoles:SetAsync(player.UserId, value)
  125.         print("Saved data for "..player.Name)
  126.     else
  127.         print("Did not manage to find data to save for "..player.Name.."!")
  128.     end
  129. end)
  130.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement