Create, Compete & Win at Redbrick Connect 2024! 🎉
SnippetReturn to first screen at the end of the game

Return to first screen at the end of the game


Example

Code

const item = WORLD.getObject("item");
const startbtn = GUI.getObject("ballstopcle_button_play_on(e77)");
const success = GUI.getObject("good_d(b37)");
const retrybtn = GUI.getObject("button_text_large_yellow_retry(8c4)");
 
success.hide();
retrybtn.hide();
startbtn.onClick(() => { //Action to execute when the start button is pressed
  startbtn.hide();
});
 
function Start() {
  item.onCollide(PLAYER, () => { //If the player touches the item, the game ends
    item.kill();
    success.show();
    setTimeout(() => {
      retrybtn.show();
    }, 2000);
  });
 
  retrybtn.onClick(() => { //Action to be executed when the restart button is pressed
    success.hide();
    PLAYER.spawn();
    item.revive();
 
    retrybtn.hide();
    startbtn.show();
  });
}