I tested this:
local val = Instance.new("IntValue")
if val.Value < 10 then
wait(3)
repeat wait(1)
print(val.Value)
val.Value += 1
until val.Value == 10
end
(A shorter and different version and it went up to nine.) I just wanted to share this, I am working on a more similar version to the old script for you.
-- OLD SCRIPT IS UNDER HERE--
-- Folders
local UIElementsF = script.Parent.Parent:WaitForChild("UIElements")
local ValuesF = script.Parent.Parent:WaitForChild("Values")
-- Value
local val = ValuesF:WaitForChild("Energy")
val:GetPropertyChangedSignal("Value"):Connect(function()
if val.Value < 100 then
task.wait(3)
repeat wait(1)
val.Value += 1
until val.Value == 100
end
end)