Advertisement
Sungmingamerpro13

FiredRBLXMan DataStore Main Game

Jun 21st, 2023 (edited)
959
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 5.36 KB | None | 0 0
  1. local TeleportService = game:GetService("TeleportService")
  2. local dVersion = 1
  3. local save = game:GetService("DataStoreService"):GetOrderedDataStore("Wins "..dVersion)
  4. local MPS = game:GetService("MarketplaceService")
  5. local VIPGamepassId = 48592364
  6.  
  7. game.Players.PlayerAdded:Connect(function(player)
  8.     local previousData = save:GetAsync(player.UserId) -- Returns a number value.
  9.  
  10.     local Wins
  11.  
  12.     if previousData ~= nil then
  13.         Wins = previousData
  14.     else
  15.         Wins = 0
  16.         save:SetAsync(player.UserId, 0)
  17.     end
  18.  
  19.     local coinsValue = Instance.new("IntValue", player)
  20.     coinsValue.Name = "Wins"
  21.     coinsValue.Value = Wins
  22. end)
  23.  
  24. game:BindToClose(function() -- Runs whenver the server is about to shut down/stop.
  25.     print("STOPPED!")
  26.  
  27.     for i,player in pairs(game.Players:GetPlayers()) do
  28.         local value = player.Wins.Value
  29.         save:SetAsync(player.UserId, value)
  30.         print("Saved data for "..player.Name)
  31.     end
  32. end)
  33.  
  34. game.Players.PlayerRemoving:Connect(function(player)
  35.     local value = player.Wins.Value
  36.  
  37.     if value ~= nil then
  38.         print("Found data to save for "..player.Name.."!")
  39.         save:SetAsync(player.UserId, value)
  40.         print("Saved data for "..player.Name)
  41.     else
  42.         print("Did not manage to find data to save for "..player.Name.."!")
  43.     end
  44. end)
  45.  
  46. local save2 = game:GetService("DataStoreService"):GetOrderedDataStore("Rounds "..dVersion)
  47.  
  48. game.Players.PlayerAdded:Connect(function(player)
  49.     local previousData = save2:GetAsync(player.UserId) -- Returns a number value.
  50.  
  51.     local Rounds
  52.  
  53.     if previousData ~= nil then
  54.         Rounds = previousData
  55.     else
  56.         Rounds = 0
  57.         save2:SetAsync(player.UserId, 0)
  58.     end
  59.  
  60.     local coinsValue = Instance.new("IntValue", player)
  61.     coinsValue.Name = "Rounds"
  62.     coinsValue.Value = Rounds
  63. end)
  64.  
  65. game:BindToClose(function() -- Runs whenver the server is about to shut down/stop.
  66.     print("STOPPED!")
  67.  
  68.     for i,player in pairs(game.Players:GetPlayers()) do
  69.         local value = player.Rounds.Value
  70.         save2:SetAsync(player.UserId, value)
  71.         print("Saved data for "..player.Name)
  72.     end
  73. end)
  74.  
  75. game.Players.PlayerRemoving:Connect(function(player)
  76.     local value = player.Rounds.Value
  77.  
  78.     if value ~= nil then
  79.         print("Found data to save for "..player.Name.."!")
  80.         save2:SetAsync(player.UserId, value)
  81.         print("Saved data for "..player.Name)
  82.     else
  83.         print("Did not manage to find data to save for "..player.Name.."!")
  84.     end
  85. end)
  86.  
  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 = game:GetService("DataStoreService"):GetOrderedDataStore("Lives "..dVersion)
  141.  
  142. game.Players.PlayerAdded:Connect(function(player)
  143.     local previousData = save3:GetAsync(player.UserId) -- Returns a number value.
  144.  
  145.     local Lives
  146.  
  147.     if previousData ~= nil then
  148.         Lives = previousData
  149.     else
  150.         Lives = 0
  151.         save3:SetAsync(player.UserId, 0)
  152.     end
  153.  
  154.     local coinsValue = Instance.new("IntValue", player)
  155.     coinsValue.Name = "Lives"
  156.     coinsValue.Value = Lives
  157.    
  158.     player.Lives.Value = 5
  159. end)
  160.  
  161. game:BindToClose(function() -- Runs whenver the server is about to shut down/stop.
  162.     print("STOPPED!")
  163.  
  164.     for i,player in pairs(game.Players:GetPlayers()) do
  165.         local value = player.Lives.Value
  166.         save3:SetAsync(player.UserId, value)
  167.         print("Saved data for "..player.Name)
  168.     end
  169. end)
  170.  
  171. game.Players.PlayerRemoving:Connect(function(player)
  172.     local value = player.Lives.Value
  173.  
  174.     if value ~= nil then
  175.         print("Found data to save for "..player.Name.."!")
  176.         save3:SetAsync(player.UserId, value)
  177.         print("Saved data for "..player.Name)
  178.     else
  179.         print("Did not manage to find data to save for "..player.Name.."!")
  180.     end
  181. end)
  182.  
  183. game.Players.PlayerRemoving:connect(function(player)
  184.  
  185.     -------------Sets the deaths once the player joins------------------------------
  186.     save2:SetAsync(player.UserId, player.Rounds.Value)
  187.     ------------------------------------------------------------------
  188. end)
  189. game.Players.PlayerAdded:connect(function(player)
  190.     player.CharacterAdded:connect(function(char)
  191.  
  192.         char.Humanoid.Died:connect(function()
  193.             player.Rounds.Value = player.Rounds.Value + 1
  194.             player.Lives.Value = player.Lives.Value - 1
  195.         end)
  196.     end)
  197. end)
  198.  
  199.  
  200.  
Tags: Roblox
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement