Got a problem with a function

function startTimer() internal {
        for(uint256 i; end != 0; i++) {
            address a = Ruglist[i];
            if(rugBalance[a].balance == 0) {
                delete rugBalance[a];
                delete Ruglist[i];
        cycle = 0;
        end = block.timestamp + duration;

why would I get this error:

Note: The called function should be payable if you send value and the value you send should be less than your current balance.

makes no sense. whatever code I error I still get error. It only works if I delete all the code from the function. I am confused asf

edit: btw ignore "rug" I want to create something like a lottery where someone looses something and everyone else gets a portion of what the person lost. and this starts a countdown, removes people that got no money and after the countdown is at 0 it will continue.

The error message does not always match with the exact problem.

In your case, I can see a non-ending for loop.

Yeah so it should function like a timer. it will check if the timer is 0 til it is. I don't know any other option to automaticlly call a function after a certain amount of time.

It doesn't work this way on blockchains. What are you doing a timer for? Usually the timing is done off-chain, not on-chain.