How to set Mouse Visibility?

Started by Dobby 3 posts 163 views

Reply on sbox.game
  1. #1
    Dobby 2,650
    Hi, sorry if this is a stupid question.
    I'm an absolute beginner when it comes to programming. 
    I only have experience with C for Arduino projects, but it looks like this doesn't help me much with S&Box. 
    I'm not able to figure it out on my own, and neither ChatGPT nor Gemini can solve my problem.

    Currently, I use Mouse.Visible = true; to make the mouse visible.
    However, I get a warning in the console telling me that I should not use this command.
    Instead, I should use the new Visibility command from the docs: https://sbox.game/api/Sandbox.Mouse.

    But I can't figure out how it works. No matter what I try, all I can get are errors.
    For now, I am still using Mouse.Visible = true, but it would be great if someone could give me an example of how I can use the new command.

  2. #2
    sleeppyy 1,185
    It's Mouse.Visibility you're supposed to use

    You need to assign it a value of the https://sbox.game/api/Sandbox.MouseVisibility enum, i.e Mouse.Visibility = MouseVisibility.Visible;
  3. #3
    Dobby Started this 2,650
    Thank you very much!
    I always tried it like this: Mouse.Visibility = true, Mouse.Visibility(Visible) in different variations.
    But your version works perfectly!