!!! —> setTimeOut() <---- is NOT —> setInterval() <---- !!!
You will need something like this…
$w.onReady(()=> {
const maxRounds=5;
const stateSwitchTime=5000;
//---------------------------------
const myMSB=$w('#Titleloop');
//---------------------------------
// Counter variable to track the number of rounds
let counter = 0;
function intervalFunction() {counter++;
console.log('Interval function triggered. Round:', counter);
if (counter===maxRounds) {
// Clear the interval when counter reaches 5-rounds.
clearInterval(intervalId);
console.log('Interval stopped after 5 rounds.');
}
else {console.log("Changing MSB-STATE...ROUND-"+counter)
myMSB.changeState('State'+counter);
}
}
const intervalId = setInterval(intervalFunction, stateSwitchTime);
});
!!! Try to get it to work. This is just an example !!!