Hi. I want a BillboardGUI to be visible when you're close to it, but disappear when you get too far away.
I tried this script, but it doesnt seem to work.
local distance = (game.Players.LocalPlayer.Character.HumanoidRootPart.Position - script.Parent.Parent.Parent.Position).magnitude while true do wait() if distance < 10 then print("visible") else print("not visible") end end
Might not be the most efficient way to do this, but I thought I'd share this anyway
You can make a hitbox for the part, so when the player touches the hitbox, the Gui will be enabled
local hitbox = *part here* local gui = *billboardgui here* local debounce = true hitbox.Touched:Connect(function(hit) if hit.Name == "HumanoidRootPart" and debounce then gui.Enabled = true debounce = false end end) hitbox.TouchEnded:Connect(function(x) if x.Name == "HumanoidRootPart" and not debounce then gui.Enabled = false debounce = true end end)
LocalScript btw
There is a property of the BillboardGUI called "MaxDistance" and it is exactly what you're looking for and measured in studs.