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.
✓ ANSWER ACCEPTED
how to decrease number value over time?
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.
