I have made a script to put a billboard Gui on a part when the player is in range with it but it’s not working, whats wrong?
local Part = nil
local Mag = nil
local Popup = script:WaitForChild("Popup")
Popup.Parent = Player.PlayerGui
repeat
wait(0.05)
if Player.Character.Humanoid.SeatPart == nil and game:IsLoaded() then
local Items = game.Workspace:GetDescendants()
for _,p in pairs(Items) do
if p.Name == "RemoteEvent" then
local Distance = (p.Position - Player.Character.HumanoidRootPart.Position).Magnitude
if Distance < 5 then
if Part == nil then
Part = p.Parent
Mag = Distance
Popup.Adornee = Part
Popup.Enabled = true
Popup.ClosestPart.Value = Part
elseif Part ~= nil and Part ~= p then
if Distance < Mag then
Part = nil
Mag = nil
Popup.Enabled = false
wait(0.025)
Part = p.Parent
Mag = Distance
Popup.Adornee = Part
Popup.Enabled = true
end
end
elseif Distance >= 5 or Distance >= Mag then
if p.Parent == Part then
wait(.1)
Part = nil
Popup.Adornee = nil
Popup.Enabled = false
elseif Part == nil then
v4 = nil
Popup.Adornee = nil
Popup.Enabled = false
Popup.ClosestPart.Value = nil
end
end
end
end
else
if game:IsLoaded() then
v3 = nil
Popup.Adornee = nil
Popup.ClosestPart.Value = nil
Popup.Enabled = false
Mag = nil
end
end
until script.Disabled == true
Go to the bottom section to skip the debugging section.
I don’t use billboard guis that often so i might be wrong but it seems to me that there’s an issue with billboard guis, the localscript does indeed make it visible but for some reason, it doesn’t show up. If you manually try to see the properties of the “Frame”, it does change the visibility to true and false depending on the distance.
Location:
.

Code:
local RunService = game:GetService("RunService")
local Workspace = game:GetService("Workspace")
local CurrentCamera = Workspace["CurrentCamera"]
local Billboard = Workspace:FindFirstChild("Part")["BillboardGui"] -- Billboard
local Frame = Billboard:FindFirstChild("Frame") -- Frame
local HumanoidRootPart = script["Parent"]:WaitForChild("HumanoidRootPart")
RunService["RenderStepped"]:Connect(function()
Frame["Visible"] = false
for Int, Item in pairs(workspace:GetChildren()) do -- Assuming the part is in the Workspace
if Item:IsA("BasePart") and Item["Name"] == "Part" then -- Checking if its a part and has the name "Part"
local Magnitude = (Item["Position"] - HumanoidRootPart["Position"])["magnitude"]
if Magnitude <= 10 then -- Checking whether the HumanoidRootPart is less than the given Range
local Position = CurrentCamera:WorldToScreenPoint(Item["Position"])
Frame["Visible"] = true -- Making the GUI visible
Frame["Position"] = UDim2.new(0, Position["X"], 0, Position["Y"], 0)
end
end
end
print(Frame["Visible"])
end)
Output:
09:25:44.003 false - Client - LocalScript:24
09:25:44.021 16.80074119567871 - Client - LocalScript:21
09:25:44.021 false - Client - LocalScript:24
09:25:44.037 16.53834342956543 - Client - LocalScript:21
09:25:44.037 false - Client - LocalScript:24
09:25:44.054 16.27608299255371 - Client - LocalScript:21
09:25:44.054 false - Client - LocalScript:24
09:25:44.070 16.013967514038086 - Client - LocalScript:21
09:25:44.070 false - Client - LocalScript:24
09:25:44.088 15.752006530761719 - Client - LocalScript:21
09:25:44.088 false - Client - LocalScript:24
09:25:44.103 15.490205764770508 - Client - LocalScript:21
09:25:44.103 false - Client - LocalScript:24
09:25:44.121 15.2285737991333 - Client - LocalScript:21
09:25:44.121 false - Client - LocalScript:24
09:25:44.137 14.967119216918945 - Client - LocalScript:21
09:25:44.137 false - Client - LocalScript:24
09:25:44.153 14.705852508544922 - Client - LocalScript:21
09:25:44.153 false - Client - LocalScript:24
09:25:44.171 14.444782257080078 - Client - LocalScript:21
09:25:44.171 false - Client - LocalScript:24
09:25:44.187 14.183919906616211 - Client - LocalScript:21
09:25:44.187 false - Client - LocalScript:24
09:25:44.204 13.92327880859375 - Client - LocalScript:21
09:25:44.204 false - Client - LocalScript:24
09:25:44.220 13.662869453430176 - Client - LocalScript:21
09:25:44.220 false - Client - LocalScript:24
09:25:44.237 13.402706146240234 - Client - LocalScript:21
09:25:44.237 false - Client - LocalScript:24
09:25:44.254 13.142804145812988 - Client - LocalScript:21
09:25:44.254 false - Client - LocalScript:24
09:25:44.270 12.883177757263184 - Client - LocalScript:21
09:25:44.270 false - Client - LocalScript:24
09:25:44.287 12.623846054077148 - Client - LocalScript:21
09:25:44.287 false - Client - LocalScript:24
09:25:44.303 12.364826202392578 - Client - LocalScript:21
09:25:44.303 false - Client - LocalScript:24
09:25:44.320 12.106136322021484 - Client - LocalScript:21
09:25:44.320 false - Client - LocalScript:24
09:25:44.337 11.84780216217041 - Client - LocalScript:21
09:25:44.337 false - Client - LocalScript:24
09:25:44.354 11.589844703674316 - Client - LocalScript:21
09:25:44.354 false - Client - LocalScript:24
09:25:44.370 11.332290649414062 - Client - LocalScript:21
09:25:44.370 false - Client - LocalScript:24
09:25:44.388 11.07516860961914 - Client - LocalScript:21
09:25:44.388 false - Client - LocalScript:24
09:25:44.403 10.818509101867676 - Client - LocalScript:21
09:25:44.403 false - Client - LocalScript:24
09:25:44.420 10.56234359741211 - Client - LocalScript:21
09:25:44.420 false - Client - LocalScript:24
09:25:44.437 10.30671215057373 - Client - LocalScript:21
09:25:44.437 false - Client - LocalScript:24
09:25:44.453 10.051653861999512 - Client - LocalScript:21
09:25:44.453 false - Client - LocalScript:24
09:25:44.470 9.797213554382324 - Client - LocalScript:21
09:25:44.470 true - Client - LocalScript:24
09:25:44.488 9.543440818786621 - Client - LocalScript:21
09:25:44.488 true - Client - LocalScript:24
09:25:44.504 9.290390968322754 - Client - LocalScript:21
09:25:44.504 true - Client - LocalScript:24
09:25:44.520 9.038124084472656 - Client - LocalScript:21
09:25:44.521 true - Client - LocalScript:24
09:25:44.537 8.786706924438477 - Client - LocalScript:21
09:25:44.537 true - Client - LocalScript:24
09:25:44.553 8.536215782165527 - Client - LocalScript:21
09:25:44.554 true - Client - LocalScript:24
09:25:44.570 8.286734580993652 - Client - LocalScript:21
09:25:44.570 true - Client - LocalScript:24
09:25:44.587 8.03835678100586 - Client - LocalScript:21
09:25:44.587 true - Client - LocalScript:24
09:25:44.603 7.791187286376953 - Client - LocalScript:21
09:25:44.603 true - Client - LocalScript:24
09:25:44.620 7.545346260070801 - Client - LocalScript:21
09:25:44.620 true - Client - LocalScript:24
09:25:44.637 7.309537887573242 - Client - LocalScript:21
09:25:44.637 true - Client - LocalScript:24
09:25:44.653 7.0869340896606445 - Client - LocalScript:21
09:25:44.653 true - Client - LocalScript:24
09:25:44.670 6.869139194488525 - Client - LocalScript:21
09:25:44.670 true - Client - LocalScript:24
09:25:44.688 6.654940128326416 - Client - LocalScript:21
09:25:44.688 true - Client - LocalScript:24
09:25:44.703 6.444657802581787 - Client - LocalScript:21
09:25:44.703 true - Client - LocalScript:24
09:25:44.720 6.238688945770264 - Client - LocalScript:21
09:25:44.720 true - Client - LocalScript:24
09:25:44.737 6.037473678588867 - Client - LocalScript:21
09:25:44.737 true - Client - LocalScript:24
09:25:44.753 5.841502666473389 - Client - LocalScript:21
09:25:44.753 true - Client - LocalScript:24
09:25:44.770 5.6513237953186035 - Client - LocalScript:21
09:25:44.770 true - Client - LocalScript:24
09:25:44.788 5.442305088043213 - Client - LocalScript:21
09:25:44.788 true - Client - LocalScript:24
09:25:44.803 5.204451084136963 - Client - LocalScript:21
09:25:44.803 true - Client - LocalScript:24
09:25:44.820 4.964737892150879 - Client - LocalScript:21
09:25:44.820 true - Client - LocalScript:24
09:25:44.837 4.8012871742248535 - Client - LocalScript:21
09:25:44.837 true - Client - LocalScript:24
09:25:44.853 4.753771781921387 - Client - LocalScript:21
09:25:44.853 true - Client - LocalScript:24
09:25:44.871 4.752111434936523 - Client - LocalScript:21
09:25:44.871 true - Client - LocalScript:24
09:25:44.888 4.75208044052124 - Client - LocalScript:21
09:25:44.888 true - Client - LocalScript:24
09:25:44.904 4.75208044052124 - Client - LocalScript:21
09:25:44.905 true - Client - LocalScript:24
09:25:44.921 4.75208044052124 - Client - LocalScript:21
09:25:44.921 true - Client - LocalScript:24
09:25:44.937 4.75208044052124 - Client - LocalScript:21
09:25:44.937 true - Client - LocalScript:24
09:25:44.953 4.75208044052124 - Client - LocalScript:21
09:25:44.954 true - Client - LocalScript:24
09:25:44.970 4.75208044052124 - Client - LocalScript:21
09:25:44.970 true - Client - LocalScript:24
09:25:44.988 4.75208044052124 - Client - LocalScript:21
09:25:44.988 true - Client - LocalScript:24
09:25:45.003 4.75208044052124 - Client - LocalScript:21
09:25:45.004 true - Client - LocalScript:24
09:25:45.020 4.75208044052124 - Client - LocalScript:21
09:25:45.020 true - Client - LocalScript:24
09:25:45.038 4.75208044052124 - Client - LocalScript:21
09:25:45.038 true - Client - LocalScript:24
09:25:45.053 4.75208044052124 - Client - LocalScript:21
09:25:45.054 true - Client - LocalScript:24
09:25:45.070 4.75208044052124 - Client - LocalScript:21
09:25:45.070 true - Client - LocalScript:24
09:25:45.087 4.75208044052124 - Client - LocalScript:21
09:25:45.087 true - Client - LocalScript:24
File:
billboard.rbxl (37.2 KB)
Alternative:
I don’t know if this is an actual issue but if you want to still try to make your script work, you can use a ScreenGui.
Example:
local RunService = game:GetService("RunService")
local Workspace = game:GetService("Workspace")
local CurrentCamera = Workspace["CurrentCamera"]
local Frame = script["Parent"]
local LocalPlayer = game:GetService("Players")["LocalPlayer"]
local HumanoidRootPart = LocalPlayer["Character"]:WaitForChild("HumanoidRootPart")
RunService["RenderStepped"]:Connect(function()
Frame["Visible"] = false
for Int, Item in pairs(workspace:GetChildren()) do
if Item:IsA("BasePart") and Item["Name"] == "Part" then
local Magnitude = (Item["Position"] - HumanoidRootPart["Position"])["magnitude"]
if Magnitude <= 10 then -- 10 is the range
local Position = CurrentCamera:WorldToScreenPoint(Item["Position"])
Frame["Visible"] = true
Frame["Position"] = UDim2.new(0, Position["X"], 0, Position["Y"], 0)
end
end
end
end)
EDIT: Screenshots.
EDIT2: File.
EDIT3: Readability.
1 Like