Advertisement
Sungmingamerpro13

My New Wins, Rounds, Roles In Story Game Lobby

Nov 5th, 2024
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 5.59 KB | None | 0 0
  1. local DatastoreService = game:GetService("DataStoreService")
  2. local TeleportService = game:GetService("TeleportService")
  3. local dVersion = 1
  4.  
  5. local VIP = 64418164
  6.  
  7. local WinsSave = DatastoreService:GetDataStore("Wins "..dVersion)
  8.  
  9. game.Players.PlayerAdded:Connect(function(player)
  10.     local previousData = WinsSave:GetAsync(player.UserId) -- Returns a number value.
  11.  
  12.     local Wins
  13.  
  14.     if previousData ~= nil then
  15.         Wins = previousData
  16.     else
  17.         Wins = 0
  18.         WinsSave:SetAsync(player.UserId, 0)
  19.     end
  20.  
  21.     local WinsValue = Instance.new("IntValue", player)
  22.     WinsValue.Name = "Wins"
  23.     WinsValue.Value = Wins
  24.  
  25. end)
  26.  
  27. game:BindToClose(function() -- Runs whenver the server is about to shut down/stop.
  28.     print("STOPPED!")
  29.  
  30.     for i,player in pairs(game.Players:GetPlayers()) do
  31.         local value = player.Wins.Value
  32.         WinsSave:SetAsync(player.UserId, value)
  33.         print("Saved data for "..player.Name)
  34.     end
  35. end)
  36.  
  37. game.Players.PlayerRemoving:Connect(function(player)
  38.     local value = player.Wins.Value
  39.  
  40.     if value ~= nil then
  41.         print("Found data to save for "..player.Name.."!")
  42.         WinsSave:SetAsync(player.UserId, value)
  43.         print("Saved data for "..player.Name)
  44.     else
  45.         print("Did not manage to find data to save for "..player.Name.."!")
  46.     end
  47. end)
  48.  
  49. local RoundsSave = DatastoreService:GetDataStore("Rounds "..dVersion)
  50.  
  51. game.Players.PlayerAdded:Connect(function(player)
  52.     local previousData = RoundsSave:GetAsync(player.UserId) -- Returns a number value.
  53.  
  54.     local Rounds
  55.  
  56.     if previousData ~= nil then
  57.         Rounds = previousData
  58.     else
  59.         Rounds = 0
  60.         RoundsSave:SetAsync(player.UserId, 0)
  61.     end
  62.  
  63.     local RoundsValue = Instance.new("IntValue", player)
  64.     RoundsValue.Name = "Rounds"
  65.     RoundsValue.Value = Rounds
  66.  
  67. end)
  68.  
  69. game:BindToClose(function() -- Runs whenver the server is about to shut down/stop.
  70.     print("STOPPED!")
  71.  
  72.     for i,player in pairs(game.Players:GetPlayers()) do
  73.         local value = player.Rounds.Value
  74.         WinsSave:SetAsync(player.UserId, value)
  75.         print("Saved data for "..player.Name)
  76.     end
  77. end)
  78.  
  79. game.Players.PlayerRemoving:Connect(function(player)
  80.     local value = player.Rounds.Value
  81.  
  82.     if value ~= nil then
  83.         print("Found data to save for "..player.Name.."!")
  84.         WinsSave:SetAsync(player.UserId, value)
  85.         print("Saved data for "..player.Name)
  86.     else
  87.         print("Did not manage to find data to save for "..player.Name.."!")
  88.     end
  89. end)
  90.  
  91. local LivesSave = DatastoreService:GetDataStore("Lives "..dVersion)
  92.  
  93. game.Players.PlayerAdded:Connect(function(player)
  94.     local previousData = LivesSave:GetAsync(player.UserId) -- Returns a number value.
  95.  
  96.     local Lives
  97.  
  98.     if previousData ~= nil then
  99.         Lives = previousData
  100.     else
  101.         Lives = 0
  102.         LivesSave:SetAsync(player.UserId, 0)
  103.     end
  104.  
  105.     local LivesValue = Instance.new("IntValue", player)
  106.     LivesValue.Name = "Lives"
  107.     LivesValue.Value = Lives
  108.  
  109. end)
  110.  
  111. game:BindToClose(function() -- Runs whenver the server is about to shut down/stop.
  112.     print("STOPPED!")
  113.  
  114.     for i,player in pairs(game.Players:GetPlayers()) do
  115.         local value = player.Lives.Value
  116.         LivesSave:SetAsync(player.UserId, value)
  117.         print("Saved data for "..player.Name)
  118.     end
  119. end)
  120.  
  121. game.Players.PlayerRemoving:Connect(function(player)
  122.     local value = player.Lives.Value
  123.  
  124.     if value ~= nil then
  125.         print("Found data to save for "..player.Name.."!")
  126.         LivesSave:SetAsync(player.UserId, value)
  127.         print("Saved data for "..player.Name)
  128.     else
  129.         print("Did not manage to find data to save for "..player.Name.."!")
  130.     end
  131. end)
  132.  
  133. local CoinsSave = DatastoreService:GetDataStore("Coins "..dVersion)
  134.  
  135. game.Players.PlayerAdded:Connect(function(player)
  136.     local previousData = CoinsSave:GetAsync(player.UserId) -- Returns a number value.
  137.  
  138.     local Coins
  139.  
  140.     if previousData ~= nil then
  141.         Coins = previousData
  142.     else
  143.         Coins = 0
  144.         CoinsSave:SetAsync(player.UserId, 0)
  145.     end
  146.  
  147.     local coinsValue = Instance.new("IntValue", player)
  148.     coinsValue.Name = "Coins"
  149.     coinsValue.Value = Coins
  150.  
  151.     local val1 = Instance.new("StringValue",player)
  152.     val1.Name = 'GotPet'
  153.     val1.Value = ''
  154.  
  155.     local val2 = Instance.new("StringValue",player)
  156.     val2.Name = 'OpenValue'
  157.     val2.Value = ''
  158.    
  159.     if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, VIP) then
  160.         player.Coins.Value = player.Coins.Value * 2
  161.     end
  162. end)
  163.  
  164. game:BindToClose(function() -- Runs whenver the server is about to shut down/stop.
  165.     print("STOPPED!")
  166.  
  167.     for i,player in pairs(game.Players:GetPlayers()) do
  168.         local value = player.Coins.Value
  169.         CoinsSave:SetAsync(player.UserId, value)
  170.         print("Saved data for "..player.Name)
  171.     end
  172. end)
  173.  
  174. game.Players.PlayerRemoving:Connect(function(player)
  175.     local value = player.Coins.Value
  176.  
  177.     if value ~= nil then
  178.         print("Found data to save for "..player.Name.."!")
  179.         CoinsSave:SetAsync(player.UserId, value)
  180.         print("Saved data for "..player.Name)
  181.     else
  182.         print("Did not manage to find data to save for "..player.Name.."!")
  183.     end
  184. end)
  185.  
  186. local SaveRoles = game:GetService("DataStoreService"):GetDataStore("Role")
  187.  
  188. game.Players.PlayerAdded:Connect(function(player)
  189.  
  190.     local  Role = Instance.new("StringValue", player)
  191.     Role.Name = "Role"
  192.     Role.Value = player.Role.Value
  193.  
  194. end)
  195.  
  196. game:BindToClose(function()
  197.     for i,player in pairs(game.Players:GetPlayers()) do
  198.         local value = player.Role.Value
  199.         SaveRoles:SetAsync(player.UserId, value)
  200.         print("Saved data for "..player.Name)
  201.     end
  202. end)
  203.  
  204. game.Players.PlayerRemoving:Connect(function(player)
  205.     local value = player.Role.Value
  206.  
  207.     if value ~= nil then
  208.         print("Found data to save for "..player.Name.."!")
  209.         SaveRoles:SetAsync(player.UserId, value)
  210.         print("Saved data for "..player.Name)
  211.     else
  212.         print("Did not manage to find data to save for "..player.Name.."!")
  213.     end
  214. end)
  215.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement