You can write your topic however you want, but you need to answer these questions:
I want to make it so the player gets cash, and if the player has a certain stat then they start generating Light Tokens. Problem is I need 2 while wait loops to do this, and I don’t know much about coroutines, so it is not working.
game.Players.PlayerAdded:Connect(function(plr)
local x = require(game.ReplicatedStorage.EternityNum)
local s = plr:WaitForChild("Data"):WaitForChild("Stats")
local r = plr:WaitForChild("Data"):WaitForChild("Runes")
local u = plr:WaitForChild("Data"):WaitForChild("Upgrades")
local money = plr:WaitForChild("Data"):WaitForChild("Stats"):WaitForChild("Money")
local multi = plr:WaitForChild("Data"):WaitForChild("Stats"):WaitForChild("Multiplier")
local reb = plr:WaitForChild("Data"):WaitForChild("Stats"):WaitForChild("Rebirths")
local sreb = plr:WaitForChild("Data"):WaitForChild("Stats"):WaitForChild("SuperRebirth")
local pres = plr:WaitForChild("Data"):WaitForChild("Stats"):WaitForChild("Prestige")
local spres = plr:WaitForChild("Data"):WaitForChild("Stats"):WaitForChild("SuperPrestige")
local lvl = plr:WaitForChild("Data"):WaitForChild("Stats"):WaitForChild("Level")
local com = plr:WaitForChild("Data"):WaitForChild("Runes"):WaitForChild("Common")
local ucom = plr:WaitForChild("Data"):WaitForChild("Runes"):WaitForChild("Uncommon")
local rare = plr:WaitForChild("Data"):WaitForChild("Runes"):WaitForChild("Rare")
local epic = plr:WaitForChild("Data"):WaitForChild("Runes"):WaitForChild("Epic")
local legend = plr:WaitForChild("Data"):WaitForChild("Runes"):WaitForChild("Legendary")
local mythic = plr:WaitForChild("Data"):WaitForChild("Runes"):WaitForChild("Mythical")
local divine = plr:WaitForChild("Data"):WaitForChild("Runes"):WaitForChild("Divine")
local adv = plr:WaitForChild("Data"):WaitForChild("Runes"):WaitForChild("Advanced")
local elite = plr:WaitForChild("Data"):WaitForChild("Runes"):WaitForChild("Elite")
local hyper = plr:WaitForChild("Data"):WaitForChild("Runes"):WaitForChild("Hyper")
local hyper = plr:WaitForChild("Data"):WaitForChild("Runes"):WaitForChild("Release")
local start1 = plr:WaitForChild("Data"):WaitForChild("PlayerData"):WaitForChild("UpgradeTreeStart")
local start2 = plr:WaitForChild("Data"):WaitForChild("Upgrades"):WaitForChild("UpgradeTreeStart")
local lt = plr:WaitForChild("Data"):WaitForChild("Stats"):WaitForChild("LightTokens")
local MoneyBoosts = {
}
local MoneyBoostsRunes = {
{Value = "Common", Function = "Multiply", Number1 = {0.0001,0}},
{Value = "Uncommon", Function = "Multiply", Number1 = {0.0003,0}},
{Value = "Rare", Function = "Multiply", Number1 = {0.001,0}},
{Value = "Epic", Function = "Multiply", Number1 = {0.005,0}},
{Value = "Legendary", Function = "Multiply", Number1 = {0.01,0}},
{Value = "Mythical", Function = "Multiply", Number1 = {1,0}},
{Value = "Divine", Function = "Multiply", Number1 = {5,0}},
{Value = "Advanced", Function = "Multiply", Number1 = {0.0002,0}},
{Value = "Elite", Function = "Multiply", Number1 = {0.0006,0}},
{Value = "Hyper", Function = "Multiply", Number1 = {0.003,0}},
{Value = "Release", Function = "Multiply", Number1 = {0.5,0}},
}
local LightTokensBoosts = {
{Value = "UpgradeTreeStart", Function = "Multiply", Number1 = {1,0}},
}
local function CalculateMultiplier(Element)
local array = MoneyBoosts[Element]
if array.Function == "Multiply" then
return x.add(x.mul(x.convert(s[array.Value].Value), array.Number1), {1,0})
elseif array.Function == "Power" then
return x.add(x.pow(x.convert(s[array.Value].Value), array.Number1), {1,0})
end
end
local function CalculateMultiplierRunes(Element2)
local array = MoneyBoostsRunes[Element2]
if array.Function == "Multiply" then
return x.add(x.mul(x.convert(r[array.Value].Value), array.Number1), {1,0})
elseif array.Function == "Power" then
return x.add(x.pow(x.convert(r[array.Value].Value), array.Number1), {1,0})
end
end
local function CalculateMultiplierLightTokens(Element)
local array = LightTokensBoosts[Element]
if array.Function == "Multiply" then
return x.add(x.mul(x.convert(u[array.Value].Value), array.Number1), {1,0})
elseif array.Function == "Power" then
return x.add(x.pow(x.convert(u[array.Value].Value), array.Number1), {1,0})
end
end
local function CalculateMoney()
local val = x.convert(1)
val = x.mul(val, x.convert(multi.Value))
for i = 1, #MoneyBoosts do
val = x.mul(val, CalculateMultiplier(i))
end
for i = 1, #MoneyBoostsRunes do
val = x.mul(val, CalculateMultiplierRunes(i))
end
local svb = x.convert(money.Value)
svb = x.add(svb,val)
money.Value = x.bnumtostr(svb)
end
local function CalculateLightTokens()
local val = x.convert(1)
val = x.mul(val, x.convert(start2.Value))
for i = 1, #LightTokensBoosts do
val = x.mul(val, CalculateLightTokens(i))
end
local svb = x.convert(lt.Value)
svb = x.add(svb,val)
lt.Value = x.bnumtostr(svb)
end
local function CalculateLevel(TableOfStats, Outcome)
for i, v in pairs(TableOfStats) do
Outcome = x.add(Outcome, x.mul(x.log10(x.add(v.Stat, {1, 0})), v.MultiplicationValue))
end
return Outcome
end
coroutine.wrap(function()
while wait(0.25) do
CalculateMoney(0.5)
lvl.Value = x.bnumtostr(CalculateLevel({
{Stat = x.convert(money.Value), MultiplicationValue = {2,0}},
{Stat = x.convert(multi.Value), MultiplicationValue = {4,0}},
{Stat = x.convert(reb.Value), MultiplicationValue = {8,0}},
{Stat = x.convert(sreb.Value), MultiplicationValue = {16,0}},
{Stat = x.convert(pres.Value), MultiplicationValue = {32,0}},
{Stat = x.convert(spres.Value), MultiplicationValue = {64,0}},
}, 0))
end
end)
coroutine.wrap(function()
while wait() do
if start1.Value == true then
while wait(1) do
CalculateLightTokens(1)
end
end
end
end)
end)