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
✓ ANSWER ACCEPTED
Why wont this script regen my custom energy?
2 answers
✓ Accepted answer
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
1 comment
0
it still doesnt work, I put a print after wait and it doesnt show. No errors though...
After while true do add a wait so it doesnt crash
1 comment
0
it doesnt crash due to the wait(RegenSpeed)
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
I think you forgot to do RegenRate.Value on line 13, or add .Value to the end of line 11