Detect workspace and gui

I’m making a game where moving takes place by clicking on the screen. But if I click on the gui buttons, then the character also runs to these points, how can I prevent this?

PlayerGui has a method that allows you to get any GuiObjects at Vector2 position. Vector2 position should be Mouse’s position. If guiobjects are nil, walk to the point.

You can fix this by enabling the Active property of GUI.

If that doesn’t work, then maybe try making a dead zone around your screen or checking if any guis are being hovered over.