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?
COMMUNITY QUESTION
How do you make a BillboardGui show up only when you're near it?
2 answers
You have to use
.magnitude
Example script:
In a Local script:
local range = 20
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hrp = char:WaitForChild("HumanoidRootPart")
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 .-.
local Door_Primary = Door.PrimaryPart
while true do
wait()
local distance = (hrp.Position - Door_Primary).magnitude
if distance <= range then
--Your code
end
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.
This discussion is preserved as it was. New answers, comments, and votes are closed.
