Ask coding questions

← Back to all posts
I have no idea why my buttons are not working
javakid999 (2)

so, I have made a lot of progress since you guys helped me out last time, but I am sadly stuck again. I have added a pause feature, and I want to make it so that you are not able to click any of the buttons when you are paused. Me and my friend have been trying for about 2 days to fix this issue, and we have no idea why it isn't working, so it would me amazing if someone out there could help me out!

heyitsmarcus (290)

You may need to do some refactoring with your code. Instead of using setTimeout try using setInterval while storing the reference to the interval in a globally accessible variable, let's say updateInterval (implement in the initial script outside of any function to hoist it into the global scope).

You'll then want to pause any updates to the game while the game is paused so you would use clearInterval(updateInterval) and then when you unpause, you would just reset the interval. I'd store the interval function into its own named function so then you can do something like setInterval(updateUI).

I don't have the time to do all of this for you, but you can do it!

Vandesm14 (1695)

Add an absolute page cover:

<div id="pageCover"></div>


#pageCover {
	position: absolute;
	z-index: 1;
	width: 100vh;
	height: 100vh;
	padding: 0;
	margin: 0;
	top: 0;
	left: 0;

Just toggle the display property of the page cover:

function showHideCover() {
	var x = document.getElementById("pageCover");
	if ( === "none") { = "block";
	} else { = "none";

Please mark this as answered if I helped your problem 👍

javakid999 (2)

@Vandesm14 hmm... This makes sense, and I put all of the code into the game, but it still appears to be doing nothing, and there are no error messages popping up.