Advertisement
Sungmingamerpro13

New Wins and Rounds with VIP(Lobby Game)

Aug 15th, 2022
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.01 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 save3 = game:GetService("DataStoreService"):GetOrderedDataStore("Level "..dVersion)
  88. local save4 = game:GetService("DataStoreService"):GetOrderedDataStore("Exp "..dVersion)
  89. local save5 = game:GetService("DataStoreService"):GetOrderedDataStore("RequiredExp "..dVersion)
  90. game.Players.PlayerAdded:Connect(function(player)
  91. local previousData = save2:GetAsync(player.UserId) -- Returns a number value.
  92. local previousData2 = save4:GetAsync(player.UserId)
  93. local previousData3 = save5:GetAsync(player.UserId)
  94.  
  95. local Level
  96. local Exp
  97. local RequiredExp
  98.  
  99. if previousData ~= nil then
  100. Level = previousData
  101. else
  102. Level = 0
  103. save3:SetAsync(player.UserId, 0)
  104. end
  105.  
  106. if previousData2 ~= nil then
  107. Exp = previousData2
  108. else
  109. Exp = 0
  110. save4:SetAsync(player.UserId, 0)
  111. end
  112.  
  113. if previousData3 ~= nil then
  114. RequiredExp = Level * 100
  115. else
  116. RequiredExp = Level * 100
  117. save5:SetAsync(player.UserId, 0)
  118. end
  119.  
  120. local coinsValue = Instance.new("IntValue", player)
  121. coinsValue.Name = "Level"
  122. coinsValue.Value = Level
  123.  
  124. local Exp = Instance.new("IntValue", player)
  125. Exp.Name = "Exp"
  126. Exp.Value = Exp
  127.  
  128. local RequiredExp = Instance.new("IntValue", player)
  129. RequiredExp.Name = "RequiredExp"
  130. RequiredExp.Value = Level * 100
  131.  
  132. -- Level Up and Exp --
  133.  
  134. Exp.Changed:Connect(function(Changed)
  135. if Exp.Value >= RequiredExp.Value then
  136. Exp.Value = 0
  137.  
  138. Level += 1
  139. RequiredExp.Value = Level * 100
  140. end
  141. end)
  142. end)
  143.  
  144. game:BindToClose(function() -- Runs whenver the server is about to shut down/stop.
  145. print("STOPPED!")
  146.  
  147. for i,player in pairs(game.Players:GetPlayers()) do
  148. local value = player.Level.Value
  149. save3:SetAsync(player.UserId, value)
  150. print("Saved data for "..player.Name)
  151. end
  152. end)
  153.  
  154. game.Players.PlayerRemoving:Connect(function(player)
  155. local value = player.Level.Value
  156.  
  157. if value ~= nil then
  158. print("Found data to save for "..player.Name.."!")
  159. save3:SetAsync(player.UserId, value)
  160. print("Saved data for "..player.Name)
  161. else
  162. print("Did not manage to find data to save for "..player.Name.."!")
  163. end
  164. end)
  165.  
  166.  
  167. local CoinsSave = game:GetService("DataStoreService"):GetOrderedDataStore("Coins "..dVersion)
  168.  
  169. game.Players.PlayerAdded:Connect(function(player)
  170. local previousData = CoinsSave:GetAsync(player.UserId) -- Returns a number value.
  171.  
  172. local Coins
  173.  
  174. if previousData ~= nil then
  175. Coins = previousData
  176. else
  177. Coins = 0
  178. CoinsSave:SetAsync(player.UserId, 0)
  179. end
  180.  
  181. local coinsValue = Instance.new("IntValue", player)
  182. coinsValue.Name = "Coins"
  183. coinsValue.Value = Coins
  184.  
  185. local val1 = Instance.new("StringValue",player)
  186. val1.Name = 'GotPet'
  187. val1.Value = ''
  188.  
  189. local val2 = Instance.new("StringValue",player)
  190. val2.Name = 'OpenValue'
  191. val2.Value = ''
  192.  
  193. if MPS:UserOwnsGamePassAsync(player.UserId, VIPGamepassId) then
  194. player.Coins.Values = player.Coins.Value *2
  195. end
  196. end)
  197.  
  198. game:BindToClose(function() -- Runs whenver the server is about to shut down/stop.
  199. print("STOPPED!")
  200.  
  201. for i,player in pairs(game.Players:GetPlayers()) do
  202. local value = player.Coins.Value
  203. CoinsSave:SetAsync(player.UserId, value)
  204. print("Saved data for "..player.Name)
  205. end
  206. end)
  207.  
  208. game.Players.PlayerRemoving:Connect(function(player)
  209. local value = player.Coins.Value
  210.  
  211. if value ~= nil then
  212. print("Found data to save for "..player.Name.."!")
  213. CoinsSave:SetAsync(player.UserId, value)
  214. print("Saved data for "..player.Name)
  215. else
  216. print("Did not manage to find data to save for "..player.Name.."!")
  217. end
  218. end)
  219. local teleportData = TeleportService:GetLocalPlayerTeleportData()
  220.  
  221. if teleportData then
  222. local Player = game.Players:GetPlayerByUserId(teleportData.PlayerName)
  223. Player:WaitForChild('Wins').Value = Player.Wins.Value + 1
  224. end
  225.  
  226.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement