Application.Quit not closing game.exe

Anyone can help me I got this code

if (raycastHit.transform.name == "stop") {
                    Application.Quit();
                }

But it doesn’t work mabey I do something wrong, anyone can help me?
I created a restart button it worked, but I also want to close the game by clicking on the quit button in the game.exe

Application.Quit doesn’t work in the editor, it only works in an actual build. If that’s not the problem, then we’re going to need a lot more code than just those two lines to tell you what’s wrong… I’d guess maybe you don’t have a collider on your button or the object the collider’s on isn’t actually named “stop”.

Forget your own manual raycasting. Try using the UI tools.

1 Like

You were right I forgot the collider, thanks for reminding me

What do you mean with that can you explain/?