Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I locally change a player's BillboardGui when they get near specific objects?

Asked by
chomboghai 2044 Moderation Voter Community Moderator
5 years ago

I've been thinking about this for a while, but I can't seem to get exactly what I am looking for.

My Problem

Basically, I have a single BillboardGui located in every player, and when they get close to a specific object, that GUI will adorn to that part, making it visible on the part. Note that this will only happen on specific parts, let's say we identify these parts by the names PartA and PartB. PartA and PartB have different GUI content, but that's not the focus here. So if the player gets close to either PartA or PartB, they will see the gui at the position of that part. There can only be one GUI active at a time, so I don't want the player to see the GUI on 5 different parts. That's why I'm using one GUI and setting its Adornee property.

I'd much rather have this than have a BillboardGui in every PartA and PartB, and set their Visible options to false/true when necessary.

Attempts

  1. One of my ideas was simply creating an additional transparent part that surrounds PartA and PartB, so when the player touches it, they will see the GUI over that object. With this, there is the issue of PartAs and PartBs potentially overlapping and causing chaos with the GUI. Also, if the player touches one of the parts, and gets very close to another PartA/PartB then the GUI will still be on the initial part, even though the player is much closer to the latter part. The GUI should adorn to whichever part is closest.

  2. I tried to use the camera with things like its lookvector property on the CFrame, and WorldToScreenPoint function but I am generally horrible with camera work and that did not go far. I feel like camera work is not necessary for this problem.

My Idea

Essentially I just need to know how far every one of the PartAs and PartBs are from my character, but I don't want to create a ton of unnecessary network communication (getting distances from parts that are very very far away), and I'm not sure how to constantly get information about the parts that are near my character. If there was some sort of function like player:GetNearbyParts(radius) then that would be perfect.

I know this is a long question but I just wanted to give as much details as possible so you guys could help me out! Thanks :)

0
Have you tried using the `TouchEnded` event of a part to detect when a player leaves the area? http://robloxdev.com/api-reference/event/BasePart/TouchEnded TheeDeathCaster 2368 — 5y
0
Unfortunately that's not what I'm looking for. BillboardGuis already have a maximum view distance property, so I don't need to un-adorn the gui when the player leaves. I'm mostly trying to look for a way to find when the player gets close to the part. chomboghai 2044 — 5y
0
Wait, wont the max view distance do that? If you get closer than the max distance it shows the GUI, otherwise it hides it. Right? greenhamster1 180 — 5y
0
I am not looking for the showing/hiding thing. My question is - how do I get references to all the parts if there will be new PartAs being created throughout the game, and both PartA and PartBs being destroyed throughout the game? chomboghai 2044 — 5y

Answer this question