Advertisement
Sungmingamerpro13

New Wins and Rounds,Money,Coins,Exp with VIP Main Game

Sep 13th, 2022 (edited)
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.37 KB | None | 0 0
  1. local DatastoreService = game:GetService("DataStoreService")
  2. local TeleportService = game:GetService("TeleportService")
  3. local dVersion = 1
  4. local save = game:GetService("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 = game:GetService("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 = 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 = DatastoreService:GetOrderedDataStore("Money "..dVersion)
  141.  
  142. game.Players.PlayerAdded:Connect(function(player)
  143. local previousData = save3:GetAsync(player.UserId) -- Returns a number value.
  144.  
  145. local Money
  146.  
  147. if previousData ~= nil then
  148. Money = previousData
  149. else
  150. Money = 0
  151. save3:SetAsync(player.UserId, 0)
  152. end
  153.  
  154. local coinsValue = Instance.new("IntValue", player)
  155. coinsValue.Name = "Money"
  156. coinsValue.Value = Money
  157. end)
  158.  
  159. game:BindToClose(function() -- Runs whenver the server is about to shut down/stop.
  160. print("STOPPED!")
  161.  
  162. for i,player in pairs(game.Players:GetPlayers()) do
  163. local value = player.Money.Value
  164. save3:SetAsync(player.UserId, value)
  165. print("Saved data for "..player.Name)
  166. end
  167. end)
  168.  
  169. game.Players.PlayerRemoving:Connect(function(player)
  170. local value = player.Money.Value
  171.  
  172. if value ~= nil then
  173. print("Found data to save for "..player.Name.."!")
  174. save3:SetAsync(player.UserId, value)
  175. print("Saved data for "..player.Name)
  176. else
  177. print("Did not manage to find data to save for "..player.Name.."!")
  178. end
  179. end)
  180.  
  181. local save3A = game:GetService("DataStoreService"):GetOrderedDataStore("Level "..dVersion)
  182. local save4 = game:GetService("DataStoreService"):GetOrderedDataStore("Exp "..dVersion)
  183. local save5 = game:GetService("DataStoreService"):GetOrderedDataStore("RequiredExp "..dVersion)
  184. game.Players.PlayerAdded:Connect(function(player)
  185. local previousData = save3A:GetAsync(player.UserId) -- Returns a number value.
  186. local previousData2 = save4:GetAsync(player.UserId)
  187. local previousData3 = save5:GetAsync(player.UserId)
  188.  
  189. local Level
  190. local Exp
  191. local RequiredExp
  192.  
  193. if previousData ~= nil then
  194. Level = previousData
  195. else
  196. Level = 0
  197. save3A:SetAsync(player.UserId, 0)
  198. end
  199.  
  200. if previousData2 ~= nil then
  201. Exp = previousData2
  202. else
  203. Exp = 0
  204. save4:SetAsync(player.UserId, 0)
  205. end
  206.  
  207. if previousData3 ~= nil then
  208. RequiredExp = Level * 100
  209. else
  210. RequiredExp = Level * 100
  211. save5:SetAsync(player.UserId, 0)
  212. end
  213.  
  214. local coinsValue = Instance.new("IntValue", player)
  215. coinsValue.Name = "Level"
  216. coinsValue.Value = Level
  217.  
  218. local Exp = Instance.new("IntValue", player)
  219. Exp.Name = "Exp"
  220. Exp.Value = Exp
  221.  
  222. local RequiredExp = Instance.new("IntValue", player)
  223. RequiredExp.Name = "RequiredExp"
  224. RequiredExp.Value = Level * 100
  225.  
  226. -- Level Up and Exp --
  227.  
  228. Exp.Changed:Connect(function(Changed)
  229. if Exp.Value >= RequiredExp.Value then
  230. Exp.Value = 0
  231.  
  232. Level += 1
  233. RequiredExp.Value = Level * 100
  234. end
  235. end)
  236. end)
  237.  
  238. game:BindToClose(function() -- Runs whenver the server is about to shut down/stop.
  239. print("STOPPED!")
  240.  
  241. for i,player in pairs(game.Players:GetPlayers()) do
  242. local value = player.Level.Value
  243. save3A:SetAsync(player.UserId, value)
  244. print("Saved data for "..player.Name)
  245. end
  246. end)
  247.  
  248. game.Players.PlayerRemoving:Connect(function(player)
  249. local value = player.Level.Value
  250.  
  251. if value ~= nil then
  252. print("Found data to save for "..player.Name.."!")
  253. save3A:SetAsync(player.UserId, value)
  254. print("Saved data for "..player.Name)
  255. else
  256. print("Did not manage to find data to save for "..player.Name.."!")
  257. end
  258. end)
  259.  
  260.  
  261. game.Players.PlayerRemoving:connect(function(player)
  262.  
  263. -------------Sets the deaths once the player joins------------------------------
  264. save2:SetAsync(player.UserId, player.Rounds.Value)
  265. ------------------------------------------------------------------
  266. end)
  267. game.Players.PlayerAdded:connect(function(player)
  268. player.CharacterAdded:connect(function(char)
  269.  
  270. char.Humanoid.Died:connect(function()
  271. player.Rounds.Value = player.Rounds.Value + 1
  272.  
  273. end)
  274. end)
  275. end)
  276.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement