-
What do you want to achieve? Trying to make a Multi-Rebirth System
-
What is the issue? Once you have enough money it just gives me 0 rebirths and it seems to not work at all.
-
What solutions have you tried so far? I have tried searching on the dev forum and rewrite it several times, none of my solutions have worked yet.
Trying to make a Multi-Rebirth System
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Remotes = ReplicatedStorage.Remotes
local RemoteFunctions = Remotes.RemoteFunctions
local RemoteEvents = Remotes.RemoteEvents
local BindableEvents = Remotes.BindableEvents
local GameSett = require(ReplicatedStorage.Data.GameSettings)
local module = {}
function search(obj)
if obj:IsA("BasePart") then
game.Debris:AddItem(obj,1)
end
for _, v in pairs(obj:GetChildren()) do
search(v)
end
end
module.Rebirth = function(p, amount)
if game:GetService("RunService"):IsStudio() or not game.Players.LocalPlayer then
if p.Life.Value >= GameSett.Settings.LifeCap then return end
if not (tonumber(p.Money.Value) >= p.Life.Price.Value) then return end
p = game.Players[p.Name]
local lib = require(ReplicatedStorage.MoneyLib)
local baseitems= p.Factory.Value.Items:GetChildren()
local items = {}
local itemList = {}
local RealSkips = 0
for i = 0, amount, 1 do
print(p.Money.Value)
if p.Life.Price.Value > p.Money.Value then
p.Money.Value -= p.Life.Price.Value
p.Life.Value += 1
RealSkips += 1
local multiplier = (10 * (math.floor(p.Life.Value / 10))) -- how many times to multiply it by x
local hunderedmultiplier = (150 * (math.floor(p.Life.Value / 100)))
local base = "2500000000000000"
for i = 1, string.len(p.Life.Value) do
base = base .. "0"
end
base = tonumber(base)
p.Life.Price.Value = ((base * p.Life.Value) * (0 >= multiplier and 1 or multiplier)) * (0 >= hunderedmultiplier and 1 or hunderedmultiplier)
end
wait()
end
for _, v in pairs(ReplicatedStorage.ShopItems:GetChildren()) do
if v:FindFirstChild("ReqLife") and (p.Life.Value + 1) >= v.ReqLife.Value and v.type.Value == 5 then
table.insert(itemList,v)
elseif v.type.Value == 5 and not v:FindFirstChild("ReqLife") then
table.insert(itemList,v)
end
end
p.Money.Value = "100"
wait()
for _, v in pairs(baseitems) do
local target = nil
for _, x in pairs(GameSett.Fusions) do
if x["PreName"] == v.Name then
target = x
break
end
end
if target then
if not items[target] then
items[target] = {1,target}
else
items[target][1] += 1
end
end
end
table.sort(items,function(x,y) return x > y end)
local item
for _, v in pairs(items) do
item = v
break
end
local rng = Random.new()
if item and item[2]["Required"] <= item[1] then
if item[2]["Required"] >= p.Items[item[2]["PreName"]].Value then
p.Items[item[2]["PreName"]]:Destroy()
else
p.Items[item[2]["PreName"]].Value -= item[2]["Required"]
end
BindableEvents.ServerAwardItem:Fire(p, item[2]["Name"], 1, workspace:GetAttribute("Names"))
BindableEvents.SayChat:Fire(p.Name .. " was reawakened into their " .. p.Life.Value .. " Life with " .. item[2]["Name"] .. "! ("..RealSkips..") Skips", item[2]["Name"], p.Name )
else
local LastItem
for i = 0, RealSkips, 1 do
local randomitem = itemList[rng:NextInteger(1,#itemList)]
LastItem = randomitem
BindableEvents.ServerAwardItem:Fire(p, randomitem.Name, 1, workspace:GetAttribute("Names"))
end
BindableEvents.SayChat:Fire(p.Name .. " was reawakened into their " .. p.Life.Value .. " Life with " .. LastItem.Name .. "! ("..RealSkips..") Skips", LastItem.Name, p.Name )
end
for _, t in pairs(p.Factory.Value.Items:GetChildren()) do
local e = Instance.new("Explosion")
e.Visible= false
e.Parent = t
e.Position = t.Hitbox.Position
e.BlastRadius = 0
end
wait()
for _, i in pairs(p.Factory.Value.Items:GetChildren()) do
if i:IsA("Model") then
if i then
if i:FindFirstChild("Explosion") then
i:WaitForChild("Explosion", 3).Visible = true
end
local s = game.Workspace.Sounds.Explode:Clone()
s.Parent = i.Hitbox
s.Volume = 0.5
s:Play()
wait(0.06)
i:Destroy()
end
end
end
p.Oil.Value = 0
if p.UnlimitedStorage.Value >= 1 then
p.SP.Value = math.huge
else
p.SP.Value = 0
end
for _, v in pairs(p.Items:GetChildren()) do
if ReplicatedStorage.Items:FindFirstChild(v.Name) then
if not ReplicatedStorage.ShopItems:FindFirstChild(v.Name).rebornproof.Value then
v:Destroy()
end
else
v:Destroy()
end
end
local n = Instance.new("NumberValue", p.Items)
n.Name = "Rusty Oil Pump"
n.Value = 1
local n2 = Instance.new("NumberValue", n)
n2.Name = "placed"
n2.Value = 0
local n1 = Instance.new("NumberValue", p.Items)
n1.Name = "Corroded Barrel"
n1.Value = 1
local n3 = Instance.new("NumberValue", n1)
n3.Name = "placed"
n3.Value = 0
p.Money.Value = 100
end
end
return module
any help with this would be amazing. thank you.
GIF: http://jay.is-pretty.sexy/64zgHje.gif