How can I make a billboard gui only appear at a certain distance

AY it works tysm do you know how I could make it so the script references all the prompts like a loop? sry idk how to code at all

I don’t must write code for you but I make it!
You need to write for all billboards or only for carrots?

1 Like

all the ones called “Eprompt”
there not just in carrots and not just in the hubworld either

is there a way to just reference everything called eprompt or do you need to know the folder its in and stuff I can provide that if needed

Okay, here’s your script:

local MAX_DISTANCE = 10 -- max distance for guis

local plr = game.Players.LocalPlayer
local rs = game:GetService("RunService")
local guis:{BillboardGui} = {}

task.wait(5) -- delay bc parts doesn't loads

for i,v in pairs(workspace:GetDescendants()) do
	if v.Name == "EPrompt" and v:IsA("BillboardGui") then
		table.insert(guis,v)
	end
end

local function calcDistance(a:BasePart,b:BasePart)
	local pos1,pos2 = a.Position,b.Position
	local dif = pos1-pos2
	return dif.Magnitude
end

rs.RenderStepped:Connect(function()
	local char = plr.Character

	if char then
		local ppart = char.PrimaryPart

		if ppart then
			for i,gui in pairs(guis) do
				local part = gui.Adornee or gui.Parent
				local d = calcDistance(part,ppart)
				
				if d > MAX_DISTANCE then
					gui.Enabled = false
				else
					gui.Enabled = true
				end
			end
		end
	end
end)

I tested it and works! Script need delay for EPrompts be in workspace

1 Like

tysm so much for the help it works

1 Like

Please mark my script as answer!

sry I forgot lol

1 Like

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