How to make Billboard Gui Hide while close to it?

I know that BillboardGui has a Distance Limit for how far it can be from a Camera to be displayed but I want to make it hide when a player is close to it how should I do that?

You can have a loop that does a magnitude check to seeif the player is close (from a localscript) then set the Visible property (or whatever it was called) to false when htey get within the distance and then set it to true when they go far enough.

1 Like

Above. You need to create your own check to enforce a minimum distance. If you’re comparing the character’s distance to a position, you can use the handy Player::DistanceFromCharacter function as opposed to a magnitude math calculation. Just remember to set an appropriate interval for your loop and don’t be making any expensive calls rapidly.


Would a while loop with a 1 second wait time be too costly?

Nope, that’d be fine. You can even chance it to 0.5.

1 Like

If the player knows when the billboard gui will be hid, then I’d do it every wait() seconds as it’ll make it seem laggy, if they don’t know when it’ll become invisible then every .5/1 seconds is fine.

I’m confused by this response you made. What do you mean by saying “if the player knows or doesn’t know when it’ll become invisible”? You shouldn’t assume the player does or doesn’t know. Just don’t run an expensive loop in rapid succession and you won’t receive any lag.

Let’s say there is a shop with a circle around it that’s visible to players. When you went in it it would display a GUI.

If the loop waits .5 seconds before running each time, when the player enters the circle they’ll have to wait .5 seconds before the appears which makes it seem unresponsive/laggy.

If the loop waits every millisecond it will be instant.

One loop checking if a player is within range of something should not lag your game, if it is you’re doing it wrong. As an extra note, you should have a denounce so that you’re not doing what you want every loop.

I’m still not following you 100%, maybe it’s because I myself am failing to understand why you’d need to go through such lengths. One loop with a small interval that checks your distance and hides the BillboardGui if you’re in a minimum distance, as described above, is all you need. 1 and 0.5 as intervals are just suggestions, if you don’t experience lag with lower intervals then go for it.

I don’t think it’d seem unresponsive or laggy since 0.5 seconds isn’t exactly that noticeable but I personally am not going to have such a loop run every 29 miliseconds, which wait does when no time argument is supplied.

I guess we have different views. I certainly notice when something is supposed to happen, but doesn’t for until .5 / 1 seconds later.

I guess kids won’t really care either.