Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

how to decrease number value over time?

how do you make a script so that every second that a number value decreases by 1? This is for a part with a number value property for when it reaches 0 it turns transparent and cancollide equals false.

1 answer

✓ Accepted answer

Two different ways to do this a for loop, and a while loop.

local countdown = 30
local block = workspace.Block
for i = countdown, 0, -1 do -- Counts down from 30 to 0, by integrals of -1
wait(1)
if i == 0 then
block.Transparency = 0
block.CanCollide = false
end
end


--OR

while countdown > 0 do
countdown = countdown - 1 
wait(1)
if countdown == 0 then
block.Transparency = 0
block.CanCollide = false
end
end

Edit: To learn more about loops click here.

This discussion is preserved as it was. New answers, comments, and votes are closed.