How can I call vgui stuff from within a sweps shared.lua

I have a function called dialog, attached to a Move hook, which looks for a input from the players mouse (it checks if the player has pressed mouse3) and if he did, it opens a dialog box. However, I keep getting errors like these “attempting to index global vgui (a nil value)”.

Why is this happening and how can I fix it?

Not that im some kind of expert but it looks like you’re trying to use vgui which is client/menu in a shared file.
Maybe this could help?

The vgui library does not exist serverside.


if CLIENT then
--stuff
end

Alternatively, make a client-side only file in which to do your client-side only code.