Advertisement
KaesK

Untitled

Apr 26th, 2020
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.25 KB | None | 0 0
  1. -- Script à mettre côté serveur :
  2.  
  3. local speedSeconde = 1 -- Peux être changé.
  4. local nomSpeedLeaderstats = "Power" -- Aussi.
  5.  
  6. script.Name = "ScriptParLulu5239" -- Ca, par contre, à ne pas changer.
  7. script.Parent = workspace
  8.  
  9. local replicateur = Instance.new("RemoteEvent")
  10. replicateur.Name = "Replicateur"
  11. replicateur.Parent = script
  12.  
  13. local rebirthEvent = Instance.new("BindableEvent")
  14.  
  15. local zaWarudo = false
  16.  
  17. local saver = Instance.new("BindableEvent")
  18. local savesPower = {}
  19. local savesRebirth = {}
  20. local savesArgent = {}
  21.  
  22. local ds = game:GetService("DataStoreService"):GetDataStore("PowerSaveSystem") -- A changer.
  23.  
  24. game.Players.PlayerAdded:Connect(function(plr)
  25.  
  26. local stats = Instance.new("Folder")
  27. stats.Name = "leaderstats"
  28. stats.Parent = plr
  29. local speedLeaderstats = Instance.new("IntValue")
  30. speedLeaderstats.Name = nomSpeedLeaderstats
  31. speedLeaderstats.Parent = stats
  32. local rebirthsLeaderstats = Instance.new("IntValue")
  33. rebirthsLeaderstats.Name = "Rebirths"
  34. rebirthsLeaderstats.Parent = stats
  35. local argentLeaderstats = Instance.new("IntValue")
  36. argentLeaderstats.Name = "Argent"
  37. argentLeaderstats.Parent = stats
  38.  
  39. local sonSpeedSeconde = speedSeconde
  40. local saVieEnMoins = 0
  41. local saResistance = 0
  42. local sonArgentSeconde = 0
  43. local sonRegen = 5
  44. local doublePower = 1
  45. local doublePowerCash = 1
  46.  
  47. local ID = tostring(plr.UserId)
  48.  
  49. local speed = ds:GetAsync(ID)
  50. if not speed then speed = 0 end
  51. local rebirths = ds:GetAsync("rebirths"..ID)
  52. if not rebirths then rebirths = 0 end
  53. local argent = ds:GetAsync("argent"..ID)
  54. if not argent then argent = 0 end
  55.  
  56. script.Changements.Event:Connect(function(joueur,nouveau,vie)
  57. if(joueur==plr.Name)then
  58. sonSpeedSeconde = nouveau * (rebirths+1)
  59. sonArgentSeconde = 0
  60. saVieEnMoins = vie
  61. end
  62. end)
  63.  
  64. workspace.System.Argent.Event:Connect(function(joueur,nouveau,vie)
  65. if(joueur==plr.Name)then
  66. sonArgentSeconde = nouveau * (rebirths+1)
  67. saVieEnMoins = vie
  68. sonSpeedSeconde = 0
  69. -- print("Demande argent...")
  70. end
  71. end)
  72.  
  73. rebirthEvent.Event:Connect(function(joueur)
  74. if(joueur.Name==plr.Name)then
  75. local val = workspace.System.PrixRebirths:FindFirstChild("Rebirth1") -- ..tostring(rebirths+1)
  76. if(val)then
  77. if(speed>=val.Value)then
  78. speed = 0
  79. rebirths = rebirths + 1
  80. plr:LoadCharacter()
  81. end
  82. else
  83. print("Pas de meilleur rebirth !")
  84. end
  85. end
  86. end)
  87.  
  88. workspace.System.Regen.Event:Connect(function(joueur,nouveau)
  89. if(joueur.Name==plr.Name)then
  90. sonRegen = nouveau
  91. -- print("Régénération : "..nouveau)
  92. end
  93. end)
  94.  
  95. workspace.System.Shop3.Event:Connect(function(joueur)
  96. if(joueur.Name==plr.Name)then
  97. if(argent>=2500)then
  98. argent = argent - 2500
  99. game.ServerStorage.DoublePowerCash:Clone().Parent = plr.Backpack
  100. end
  101. end
  102. end)
  103.  
  104. workspace.System.Shop2.Event:Connect(function(joueur)
  105. if(joueur.Name==plr.Name)then
  106. if(argent>=1000)then
  107. argent = argent - 1000
  108. game.ServerStorage.DoublePower:Clone().Parent = plr.Backpack
  109. end
  110. end
  111. end)
  112.  
  113. workspace.System.Shop1.Event:Connect(function(joueur)
  114. if(joueur.Name==plr.Name)then
  115. if(argent>=1000)then
  116. argent = argent - 1000
  117. game.ServerStorage.Masque:Clone().Parent = plr.Backpack
  118. end
  119. end
  120. end)
  121.  
  122. workspace.System.ZaWarudo.OnServerEvent:Connect(function(joueur)
  123. if zaWarudo == false then
  124. if(plr.Name==joueur.Name)then
  125. if(rebirths>0)then
  126. zaWarudo = true
  127. workspace.System.ZaWarudo:FireAllClients(rebirths,rebirths)
  128. wait(rebirths)
  129. wait(table.getn(game.Players:GetChildren())*5)
  130. zaWarudo = false
  131. end
  132. end
  133. end
  134. end)
  135.  
  136. workspace.System.DoublePower.Event:Connect(function(joueur,nouveau)
  137. if(joueur.Name==plr.Name)then
  138. if(nouveau)then
  139. doublePower = 2
  140. else
  141. doublePower = 1
  142. end
  143. -- print("Régénération : "..nouveau)
  144. end
  145. end)
  146.  
  147. workspace.System.DoublePowerCash.Event:Connect(function(joueur,nouveau)
  148. if(joueur.Name==plr.Name)then
  149. if(nouveau)then
  150. doublePowerCash = 2
  151. else
  152. doublePowerCash = 1
  153. end
  154. -- print("Régénération : "..nouveau)
  155. end
  156. end)
  157.  
  158. plr.CharacterAdded:Connect(function()
  159. wait(1)
  160. plr.Character.Humanoid.Health = plr.Character.Humanoid.MaxHealth
  161. end)
  162.  
  163. saver.Event:Connect(function(p)
  164. if(p==ID)then
  165. -- print("Ca va se sauvegarder...")
  166. ds:SetAsync(p,speed)
  167. ds:SetAsync("rebiths"..p,rebirths)
  168. ds:SetAsync("argent"..p,argent)
  169. -- print("Ca s'est sauvegardé.")
  170. print("Ca a bien sauvegardé !")
  171. end
  172. end)
  173.  
  174. local i = 0
  175.  
  176. while plr do
  177. i=i+1
  178. pcall(function()
  179. plr.Character.Humanoid.WalkSpeed = speed / 10
  180. plr.Character.Humanoid.JumpPower = math.sqrt(speed / 10)
  181. plr.Character.Humanoid.MaxHealth = speed + 1
  182. saResistance = speed / 10
  183. saResistance = 0
  184. plr.Character.Humanoid.Health = plr.Character.Humanoid.Health - (saVieEnMoins - saResistance)
  185. if(plr.Character.Humanoid.Health>0)then
  186. speed = (speed + sonSpeedSeconde) * doublePower * doublePowerCash
  187. argent = (argent + sonArgentSeconde) * doublePowerCash
  188. end
  189.  
  190. -- Régénération
  191. wait(0.01)
  192. plr.Character.Humanoid.Health = plr.Character.Humanoid.Health + (plr.Character.Humanoid.MaxHealth * (sonRegen/100))
  193. end)
  194. speedLeaderstats.Value = speed
  195. savesPower[ID] = speed
  196. argentLeaderstats.Value = argent
  197. savesArgent[ID] = argent
  198. savesRebirth[ID] = rebirths
  199. rebirthsLeaderstats.Value = rebirths
  200. if(math.fmod(i,30)==0)then
  201. ds:SetAsync(ID,savesPower[ID])
  202. ds:SetAsync("rebirths"..ID,savesRebirth[ID])
  203. ds:SetAsync("argent"..ID,savesArgent[ID])
  204. print("Correctement sauvegardé : "..plr.Name)
  205. end
  206. wait(0.99)
  207. end
  208.  
  209. -- saver:Fire(plr.UserId)
  210. end)
  211.  
  212. --game.Players.PlayerRemoving:Connect(function(p) saver:Fire(p.UserId) end)
  213. game.Players.PlayerRemoving:Connect(function(plr)
  214. print("Dois sauvegarder : "..plr.Name)
  215. local p = tostring(plr.UserId)
  216. ds:SetAsync(p,savesPower[p])
  217. ds:SetAsync("rebiths"..p,savesRebirth[p])
  218. ds:SetAsync("argent"..p,savesArgent[p])
  219. print("Correctement sauvegardé : "..plr.Name)
  220. end)
  221.  
  222. workspace.System.Rebirth.OnServerEvent:Connect(function(plr)
  223. rebirthEvent:Fire(plr)
  224. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement