Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why wont this script regen my custom energy?

Asked by 4 years ago
local RegenSpeed = 0.25


local energylvl = script.Parent.Energy
local energyMAX = script.Parent.EnergyMAX


while true do
    local energylvl = script.Parent.Energy
    local energyMAX = script.Parent.EnergyMAX
    local RegenRate = script.Parent.RegenRate
    while energylvl.Value < energyMAX.Value do
        energylvl.Value = energylvl.Value + RegenRate
        wait(RegenSpeed)
    end
    end
0
I think you forgot to do RegenRate.Value on line 13, or add .Value to the end of line 11 lucas4114 607 — 4y

2 answers

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago
local RegenSpeed = 0.25


 local energylvl = script.Parent.Energy
 local energyMAX = script.Parent.EnergyMAX
 local RegenRate = script.Parent.RegenRate


while true do
    if energylvl.Value < energyMAX.Value then--make it an if statement instead, not much more you can change
        energylvl.Value = energylvl.Value + RegenRate.Value--you forgot to tell it to add the value of the regenrate
        wait(RegenSpeed)
    end
    end
0
it still doesnt work, I put a print after wait and it doesnt show. No errors though... tightanfall 110 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

After while true do add a wait so it doesnt crash

0
it doesnt crash due to the wait(RegenSpeed) tightanfall 110 — 4y

Answer this question