Advertisement
Sungmingamerpro13

JohnRBLX And FiredManRBLX Wins and Rounds System Lobby Game

Sep 13th, 2022
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.01 KB | None | 0 0
  1. local DatastoreService = game:GetService("DataStoreService")
  2. local TeleportService = game:GetService("TeleportService")
  3. local dVersion = 1
  4. local save = DatastoreService:GetOrderedDataStore("Wins "..dVersion)
  5. local MPS = game:GetService("MarketplaceService")
  6. local VIPGamepassId = 25177570
  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 = 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 = 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 save3A = game:GetService("DataStoreService"):GetOrderedDataStore("Level "..dVersion)
  141. local save4 = game:GetService("DataStoreService"):GetOrderedDataStore("Exp "..dVersion)
  142. local save5 = game:GetService("DataStoreService"):GetOrderedDataStore("RequiredExp "..dVersion)
  143. game.Players.PlayerAdded:Connect(function(player)
  144. local previousData = save3A:GetAsync(player.UserId) -- Returns a number value.
  145. local previousData2 = save4:GetAsync(player.UserId)
  146. local previousData3 = save5:GetAsync(player.UserId)
  147.  
  148. local Level
  149. local Exp
  150. local RequiredExp
  151.  
  152. if previousData ~= nil then
  153. Level = previousData
  154. else
  155. Level = 0
  156. save3A:SetAsync(player.UserId, 0)
  157. end
  158.  
  159. if previousData2 ~= nil then
  160. Exp = previousData2
  161. else
  162. Exp = 0
  163. save4:SetAsync(player.UserId, 0)
  164. end
  165.  
  166. if previousData3 ~= nil then
  167. RequiredExp = Level * 100
  168. else
  169. RequiredExp = Level * 100
  170. save5:SetAsync(player.UserId, 0)
  171. end
  172.  
  173. local coinsValue = Instance.new("IntValue", player)
  174. coinsValue.Name = "Level"
  175. coinsValue.Value = Level
  176.  
  177. local Exp = Instance.new("IntValue", player)
  178. Exp.Name = "Exp"
  179. Exp.Value = Exp
  180.  
  181. local RequiredExp = Instance.new("IntValue", player)
  182. RequiredExp.Name = "RequiredExp"
  183. RequiredExp.Value = Level * 100
  184.  
  185. -- Level Up and Exp --
  186.  
  187. Exp.Changed:Connect(function(Changed)
  188. if Exp.Value >= RequiredExp.Value then
  189. Exp.Value = 0
  190.  
  191. Level += 1
  192. RequiredExp.Value = Level * 100
  193. end
  194. end)
  195. end)
  196.  
  197. game:BindToClose(function() -- Runs whenver the server is about to shut down/stop.
  198. print("STOPPED!")
  199.  
  200. for i,player in pairs(game.Players:GetPlayers()) do
  201. local value = player.Level.Value
  202. save3A:SetAsync(player.UserId, value)
  203. print("Saved data for "..player.Name)
  204. end
  205. end)
  206.  
  207. game.Players.PlayerRemoving:Connect(function(player)
  208. local value = player.Level.Value
  209.  
  210. if value ~= nil then
  211. print("Found data to save for "..player.Name.."!")
  212. save3A:SetAsync(player.UserId, value)
  213. print("Saved data for "..player.Name)
  214. else
  215. print("Did not manage to find data to save for "..player.Name.."!")
  216. end
  217. end)
  218.  
  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