Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Script à mettre côté serveur :
- local speedSeconde = 1 -- Peux être changé.
- local nomSpeedLeaderstats = "Power" -- Aussi.
- script.Name = "ScriptParLulu5239" -- Ca, par contre, à ne pas changer.
- script.Parent = workspace
- local replicateur = Instance.new("RemoteEvent")
- replicateur.Name = "Replicateur"
- replicateur.Parent = script
- local rebirthEvent = Instance.new("BindableEvent")
- local zaWarudo = false
- local saver = Instance.new("BindableEvent")
- local savesPower = {}
- local savesRebirth = {}
- local savesArgent = {}
- local ds = game:GetService("DataStoreService"):GetDataStore("PowerSaveSystem") -- A changer.
- game.Players.PlayerAdded:Connect(function(plr)
- local stats = Instance.new("Folder")
- stats.Name = "leaderstats"
- stats.Parent = plr
- local speedLeaderstats = Instance.new("IntValue")
- speedLeaderstats.Name = nomSpeedLeaderstats
- speedLeaderstats.Parent = stats
- local rebirthsLeaderstats = Instance.new("IntValue")
- rebirthsLeaderstats.Name = "Rebirths"
- rebirthsLeaderstats.Parent = stats
- local argentLeaderstats = Instance.new("IntValue")
- argentLeaderstats.Name = "Argent"
- argentLeaderstats.Parent = stats
- local sonSpeedSeconde = speedSeconde
- local saVieEnMoins = 0
- local saResistance = 0
- local sonArgentSeconde = 0
- local sonRegen = 5
- local doublePower = 1
- local doublePowerCash = 1
- local ID = tostring(plr.UserId)
- local speed = ds:GetAsync(ID)
- if not speed then speed = 0 end
- local rebirths = ds:GetAsync("rebirths"..ID)
- if not rebirths then rebirths = 0 end
- local argent = ds:GetAsync("argent"..ID)
- if not argent then argent = 0 end
- script.Changements.Event:Connect(function(joueur,nouveau,vie)
- if(joueur==plr.Name)then
- sonSpeedSeconde = nouveau * (rebirths+1)
- sonArgentSeconde = 0
- saVieEnMoins = vie
- end
- end)
- workspace.System.Argent.Event:Connect(function(joueur,nouveau,vie)
- if(joueur==plr.Name)then
- sonArgentSeconde = nouveau * (rebirths+1)
- saVieEnMoins = vie
- sonSpeedSeconde = 0
- -- print("Demande argent...")
- end
- end)
- rebirthEvent.Event:Connect(function(joueur)
- if(joueur.Name==plr.Name)then
- local val = workspace.System.PrixRebirths:FindFirstChild("Rebirth1") -- ..tostring(rebirths+1)
- if(val)then
- if(speed>=val.Value)then
- speed = 0
- rebirths = rebirths + 1
- plr:LoadCharacter()
- end
- else
- print("Pas de meilleur rebirth !")
- end
- end
- end)
- workspace.System.Regen.Event:Connect(function(joueur,nouveau)
- if(joueur.Name==plr.Name)then
- sonRegen = nouveau
- -- print("Régénération : "..nouveau)
- end
- end)
- workspace.System.Shop3.Event:Connect(function(joueur)
- if(joueur.Name==plr.Name)then
- if(argent>=2500)then
- argent = argent - 2500
- game.ServerStorage.DoublePowerCash:Clone().Parent = plr.Backpack
- end
- end
- end)
- workspace.System.Shop2.Event:Connect(function(joueur)
- if(joueur.Name==plr.Name)then
- if(argent>=1000)then
- argent = argent - 1000
- game.ServerStorage.DoublePower:Clone().Parent = plr.Backpack
- end
- end
- end)
- workspace.System.Shop1.Event:Connect(function(joueur)
- if(joueur.Name==plr.Name)then
- if(argent>=1000)then
- argent = argent - 1000
- game.ServerStorage.Masque:Clone().Parent = plr.Backpack
- end
- end
- end)
- workspace.System.ZaWarudo.OnServerEvent:Connect(function(joueur)
- if zaWarudo == false then
- if(plr.Name==joueur.Name)then
- if(rebirths>0)then
- zaWarudo = true
- workspace.System.ZaWarudo:FireAllClients(rebirths,rebirths)
- wait(rebirths)
- wait(table.getn(game.Players:GetChildren())*5)
- zaWarudo = false
- end
- end
- end
- end)
- workspace.System.DoublePower.Event:Connect(function(joueur,nouveau)
- if(joueur.Name==plr.Name)then
- if(nouveau)then
- doublePower = 2
- else
- doublePower = 1
- end
- -- print("Régénération : "..nouveau)
- end
- end)
- workspace.System.DoublePowerCash.Event:Connect(function(joueur,nouveau)
- if(joueur.Name==plr.Name)then
- if(nouveau)then
- doublePowerCash = 2
- else
- doublePowerCash = 1
- end
- -- print("Régénération : "..nouveau)
- end
- end)
- plr.CharacterAdded:Connect(function()
- wait(1)
- plr.Character.Humanoid.Health = plr.Character.Humanoid.MaxHealth
- end)
- saver.Event:Connect(function(p)
- if(p==ID)then
- -- print("Ca va se sauvegarder...")
- ds:SetAsync(p,speed)
- ds:SetAsync("rebiths"..p,rebirths)
- ds:SetAsync("argent"..p,argent)
- -- print("Ca s'est sauvegardé.")
- print("Ca a bien sauvegardé !")
- end
- end)
- local i = 0
- while plr do
- i=i+1
- pcall(function()
- plr.Character.Humanoid.WalkSpeed = speed / 10
- plr.Character.Humanoid.JumpPower = math.sqrt(speed / 10)
- plr.Character.Humanoid.MaxHealth = speed + 1
- saResistance = speed / 10
- saResistance = 0
- plr.Character.Humanoid.Health = plr.Character.Humanoid.Health - (saVieEnMoins - saResistance)
- if(plr.Character.Humanoid.Health>0)then
- speed = (speed + sonSpeedSeconde) * doublePower * doublePowerCash
- argent = (argent + sonArgentSeconde) * doublePowerCash
- end
- -- Régénération
- wait(0.01)
- plr.Character.Humanoid.Health = plr.Character.Humanoid.Health + (plr.Character.Humanoid.MaxHealth * (sonRegen/100))
- end)
- speedLeaderstats.Value = speed
- savesPower[ID] = speed
- argentLeaderstats.Value = argent
- savesArgent[ID] = argent
- savesRebirth[ID] = rebirths
- rebirthsLeaderstats.Value = rebirths
- if(math.fmod(i,30)==0)then
- ds:SetAsync(ID,savesPower[ID])
- ds:SetAsync("rebirths"..ID,savesRebirth[ID])
- ds:SetAsync("argent"..ID,savesArgent[ID])
- print("Correctement sauvegardé : "..plr.Name)
- end
- wait(0.99)
- end
- -- saver:Fire(plr.UserId)
- end)
- --game.Players.PlayerRemoving:Connect(function(p) saver:Fire(p.UserId) end)
- game.Players.PlayerRemoving:Connect(function(plr)
- print("Dois sauvegarder : "..plr.Name)
- local p = tostring(plr.UserId)
- ds:SetAsync(p,savesPower[p])
- ds:SetAsync("rebiths"..p,savesRebirth[p])
- ds:SetAsync("argent"..p,savesArgent[p])
- print("Correctement sauvegardé : "..plr.Name)
- end)
- workspace.System.Rebirth.OnServerEvent:Connect(function(plr)
- rebirthEvent:Fire(plr)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement