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

How do you make a BillboardGui show up only when you're near it?

Asked by
Exadide 15
5 years ago

I have this door system, where when you're near it I'd like for it to say "Press E to open." However, the GUI only shows up when you're near it with your camera, not your player. How do you make it so that the BillboardGui pops up only when your character is near it, not the camera?

2 answers

Log in to vote
0
Answered by 5 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.

You have to use

1.magnitude

Example script:

In a Local script:

01local range = 20
02local plr = game.Players.LocalPlayer
03local char = plr.Character or plr.CharacterAdded:Wait()
04local hrp = char:WaitForChild("HumanoidRootPart")
05local Door = workspace.Door --You can have more than one door I think you have to use a loop then cuz I already made something like that .-.
06 
07local Door_Primary = Door.PrimaryPart
08 
09while true do
10wait()
11local distance = (hrp.Position - Door_Primary).magnitude
12if distance <= range then
13--Your code
14end
15end
Ad
Log in to vote
0
Answered by 5 years ago

Hello, Exadide. You don't even need a script. Just set the BilboardGui's "MaxDistance" property to the maximum distance you want. Please accept this answer and upvote it if it helped you.

Answer this question