Billboard Gui distance not working

Anyone know how to make a billboard gui only appear depending on how far away the player’s character is?
Currently there is a property which hides it if your camera is too far away but this means if a player is right next to it with a really zoomed out camera it won’t show :frowning: I want it to be based on character root distance and not camera distance
I know there is a way by checking magnitude frequently but I was hoping for an easier way


Not sure if this would completely work but as you said, magnitude checking might be a good option here. Having a while loop with magnitude checks between the player and part with the Billboard UI could be an option, where you’d disable the billboard UI if they were X amount of studs away.

local billboardUI = PATH_TO_BILLBOARDUI
local part = PATH_TO_PART
local maxDistance = 20
local player = game:GetService("Players").LocalPlayer

while wait() do
	if player:FindFirstChild("Humanoid") ~= nil then
		local studs = (part.Position - player.Character.HumanoidRootPart.Position).Magnitude
		if studs <= 20 then
			billboardUI.Enabled = true
			billboardUI.Enabled = false

This is the only thing I could think of from the top of my head. Hope this helps!


yeah it j;ust seems ridiculousj to run an infinite loop for something so simple also I have alot of guis I want to do this for so think how many loops i’;ll need

1 Like

Put the billboard Guis in a folder in player gui, then put this code in a local script

local player = game.Players.LocalPlayer
local BGUI_Folder = player.PlayerGui:WaitForChild("BGUI_Folder")
local maxDistance = 20

game["Run Service"].RenderStepped:Connect(function()
	for i, gui in pairs(BGUI_Folder:GetChildren()) do
		if not player.Character then return end
		if not gui.Adornee then return end
		local distance = (gui.Adornee.Position - player.Character.HumanoidRootPart).Magnitude
		if distance <= maxDistance then
			gui.Enabled = true
			gui.Enabled = false
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.