How to disable remove when item clicked event from (Item)

I wanted to know if there was a way to disable the Remove when item clicked event code after a couple of seconds have past is that possible?

Hi @JohnSpace,

You can use ā€œRemove when item clickā€ CoBlock from Events Category

I donā€™t have the option to put it in no items Iā€™m trying to disable the remove when item clicked after a couple of seconds so that I can click on the item again

Try this code, but swap out the cuboid with your item:

Hope that helps!!
TheDiamondKiwi

Hi @JohnSpace,

Judging from the posts above, weā€™re not entirely clear on what youā€™re trying to achieve.

Could you share the code youā€™re using by selecting the part thatā€™s causing you problems and right-clicking and selecting Save as Image, or allow your project to be remixed and share the link, so that we can see the context for your description, and suggest appropriate solutions?

Thanks,
Geoff @ TechLeap

Sorry about that Iā€™m not sure how to explain it go to scene 3 Iā€™m trying to make a turn based rpg game CoSpaces Edu :: Tom's Mysterious Rpg Adventure (Test) I wanna make it so that when I click on fight it will activate the remove when item clicked event code then after a couple of seconds it will deactivate the remove when item clicked event code

Iā€™ll go try that out (Also if you donā€™t understand what I mean here is a link) CoSpaces Edu :: Tomā€™s Mysterious Rpg Adventure (Test)

Do you just want to deactivate the button while the action is taking place? In other platforms I have achieved button activate and deactivate using a Boolean (True/False) variable. Set ā€˜buttonClickableā€™ to true on start.
If (buttonClickable == true)
{When clicked
{
buttonClickable= false;
//do function;
}
}
Then set the buttonClickable back to true whenever you want it clickable again either after a set time or when the other actions are completed.

Is that what you were thinking?

You could create a function that initialises the onClick event. And schedule this function call when the event was disposed.

function setOnClick() {
  obj.input.onClick(()=>{
    //your onclick logic
    obj.input.onClick(null)
    Time.schedule(setOnClick, 2)
  })
}

setOnClick();
1 Like

I think yes that is correct let me try it

Wait how do I set a timer with scripting I havenā€™t really learned that yet

let time = 10;
let timeDisplay = Scene.getItem("Item ID Here") as Text;
timeDisplay.Text = "Time: " + time;

Time.scheduleRepeating(()=>{
        if (time = 0){
             timeDisplay.Text = "Time is up!"
             dispose();}

    else{
          time -= 1;
          timeDisplay.Text = "Time: " + time;}, 
1);

Function schedule executes a function after a delay in seconds.

Time.schedule(()=>{
  /*your code here*/
}, delay);