Advertisement
Sungmingamerpro13

My New Wins and Rounds Main + Roles

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