Normally billboard gui's are dependant on where exactly the camera is in relation to the parent of the gui. What I want to do is make it so the visibility of the gui dependant on how close the player is to an object. An example is the jailbreak cars and their system of using "e" to interact depending on how close the player is. What should I do?
COMMUNITY QUESTION
How do you make a billboard gui that depends on how close the player is?
1 answer
use magnitude. if you're 100 studs away from the billboard, the text shows.
-- THIS IS A LOCAL SCRIPT
local text = game.Workspace.BillBoard.SurfaceGui.TextLabel--finding the text
local billboard = game.Workspace.BillBoard--finding the billboard
while wait() do--while loop
local mag = (billboard.Position-game.Players.LocalPlayer.Character.HumanoidRootPart.Position).magnitude --using magnitude to identify how far away you are from the billboard
if mag <= 15 then-- if the magnitude is smaller or equal to 15
text.Visible = true -- if it is, the billboard is visible
else
text.Visible = false --otherwise, we make the text invisible
end
end
1 comment
0
but to reduce lag would you suggest having a wait for like 0.5 seconds?
This discussion is preserved as it was. New answers, comments, and votes are closed.

6 comments
You could probably use a Touched event.
Or getting the magnitude between two objects. For example: The car and the player's humanoid root part.
It would have to be in a loop, right?
maybe
I'd create an invisible part and when the player is in the part enable the gui.
Not a bad idea, but it could cause more lag than having a loop with a specific time checking interval.