How can I change the time it takes to loop through this code immediately on UserInput?

Hey developers!

I’m currently working on a version of Tetris in Roblox, and I have a function that slowly drops each tetromino per set amount of time. Here’s a quick example:

local speed = 1

while wait(speed) do
     LowerTetromino()
end

The idea is that when a user holds down the S/down key, the value of speed decreases and ultimately causes the tetromino to fall quicker. Is there a way I’d be able to apply that speed to the loop immediately without waiting for the previous speed to finish waiting?