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?
You have to use
1 | .magnitude |
Example script:
In a Local script:
01 | local range = 20 |
02 | local plr = game.Players.LocalPlayer |
03 | local char = plr.Character or plr.CharacterAdded:Wait() |
04 | local hrp = char:WaitForChild( "HumanoidRootPart" ) |
05 | local 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 |
07 | local Door_Primary = Door.PrimaryPart |
08 |
09 | while true do |
10 | wait() |
11 | local distance = (hrp.Position - Door_Primary).magnitude |
12 | if distance < = range then |
13 | --Your code |
14 | end |
15 | end |
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.