Advertisement
Sungmingamerpro13

My New Wins, Rounds, Roles In Story Game Main

Nov 5th, 2024 (edited)
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 6.34 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.     if player:WaitForChild("Role").Value >= "Default" then
  195.         player:WaitForChild("Role").Value = "Default"
  196.     elseif player:WaitForChild("Role").Value == "Athlete" then
  197.         player:WaitForChild("Role").Value = "Athlete"
  198.     elseif player:WaitForChild("Role").Value == "Super Protector" then
  199.         player:WaitForChild("Role").Value = "Super Protector"
  200.     elseif player:WaitForChild("Role").Value == "Delivery" then
  201.         player:WaitForChild("Role").Value = "Delivery"
  202.         game.ServerStorage.SavedTools:WaitForChild("PizzaBox"):Clone().Parent = player.Backpack
  203.     end
  204.  
  205. end)
  206.  
  207. game:BindToClose(function()
  208.     for i,player in pairs(game.Players:GetPlayers()) do
  209.         local value = player.Role.Value
  210.         SaveRoles:SetAsync(player.UserId, value)
  211.         print("Saved data for "..player.Name)
  212.     end
  213. end)
  214.  
  215. game.Players.PlayerRemoving:Connect(function(player)
  216.     local value = player.Role.Value
  217.  
  218.     if value ~= nil then
  219.         print("Found data to save for "..player.Name.."!")
  220.         SaveRoles:SetAsync(player.UserId, value)
  221.         print("Saved data for "..player.Name)
  222.     else
  223.         print("Did not manage to find data to save for "..player.Name.."!")
  224.     end
  225. end)
  226.  
  227. game.Players.PlayerAdded:Connect(function(player)
  228.     player.CharacterAdded:Connect(function(Char)
  229.  
  230.         Char.Humanoid.Died:Connect(function()
  231.  
  232.             player.Rounds.Value = player.Rounds.Value + 1
  233.  
  234.         end)
  235.     end)
  236. end)
  237.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement