Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local bGUIs = {}
- local player = game.Players.LocalPlayer
- local playerGUI = player:WaitForChild("PlayerGui")
- local function getAllBillboardGuis(parent)
- local iterations = 0 -- every 200, wait() (reduces lag)
- local guis = {}
- local function get(p)
- for i,v in pairs(p:GetChildren()) do
- iterations = iterations + 1
- if (iterations % 200 == 0) then
- wait()
- end
- if (#v:GetChildren() > 0) and (not v:IsA("BillboardGui")) then
- get(v)
- elseif (v:IsA("BillboardGui")) then
- table.insert(guis, v)
- end
- end
- end
- get(parent)
- return guis
- end
- workspace.DescendantAdded:connect(function(d)
- if (d:IsA("BillboardGui")) then
- repeat
- wait()
- until d.Parent
- wait()
- table.insert(bGUIs, d)
- end
- end)
- playerGUI.DescendantAdded:connect(function(d)
- if (d:IsA("BillboardGui")) then
- repeat
- wait()
- until d.Parent
- wait()
- table.insert(bGUIs, d)
- end
- end)
- bGUIs = getAllBillboardGuis(workspace)
- while wait(0.25) do
- for i,v in pairs(bGUIs) do
- local part = v.Adornee or v.Parent
- if (part) then
- if (player:DistanceFromCharacter(part.Position) > 50) then
- v.Enabled = false
- else
- v.Enabled = true
- end
- else
- table.remove(bGUIs, i) -- cleanup dead references
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement