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

How do you make a billboard gui that depends on how close the player is?

Asked by 5 years ago

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?

0
You could probably use a Touched event. namespace25 594 — 5y
0
Or getting the magnitude between two objects. For example: The car and the player's humanoid root part. namespace25 594 — 5y
0
It would have to be in a loop, right? greenhamster1 180 — 5y
0
maybe DeceptiveCaster 3761 — 5y
View all comments (2 more)
0
I'd create an invisible part and when the player is in the part enable the gui. Twenty1chickens 4 — 5y
0
Not a bad idea, but it could cause more lag than having a loop with a specific time checking interval. greenhamster1 180 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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
0
but to reduce lag would you suggest having a wait for like 0.5 seconds? greenhamster1 180 — 5y
Ad

Answer this question