Advertisement
Sungmingamerpro13

Technobrother, HammamParwazMP, TimRBLX Main Game DataStore

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