#Energy Restoring System

4 messages · Page 1 of 1 (latest)

haughty whale
#

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)

haughty whale
#

I got it @shut echo.

-- Folders
local UIElementsF = script.Parent.Parent:WaitForChild("UIElements")
local ValuesF = script.Parent.Parent:WaitForChild("Values")
-- Value
local val = ValuesF:WaitForChild("Energy")

function addVal()
for i = 0, 1, 1 do
wait(1)
if val.Value == 100 then
return(addVal())
else
val.Value += 1
print(val.Value)
end
if i == 1 then do
addVal()
end
end
end
end

val:GetPropertyChangedSignal("Value"):Connect(function()
if val.Value < 100 then
wait(3)
addVal()
end
end)

shut echo
#

thanks so much @haughty whale :)

#

You helped a lot thanks again