local Players = game:GetService("Players")
local player = Players.LocalPlayer
local basesFolder = workspace:WaitForChild("Bases")
local function setGuiVisible(billboardGui, visible)
for _, child in billboardGui:GetChildren() do
if child:IsA("TextLabel") then
child.TextTransparency = visible and 0 or 1
for _, desc in child:GetChildren() do
if desc:IsA("UIStroke") then
desc.Transparency = visible and 0 or 1
end
end
elseif child:IsA("ImageLabel") then
child.ImageTransparency = visible and 0 or 1
for _, desc in child:GetChildren() do
if desc:IsA("UIStroke") then
desc.Transparency = visible and 0 or 1
end
end
end
end
end
local function getOwnerName(base)
local values = base:FindFirstChild("Values")
if values then
local owner = values:FindFirstChild("Owner")
if owner and owner:IsA("StringValue") then
return owner.Value
end
end
return ""
end
local function isInsideZone(character, zone)
local hrp = character:FindFirstChild("HumanoidRootPart")
if not hrp then return false end
local charPos = hrp.Position
local zoneCF = zone.CFrame
local zoneSize = zone.Size
local localPos = zoneCF:PointToObjectSpace(charPos)
local halfSize = zoneSize / 2
return math.abs(localPos.X) <= halfSize.X
and math.abs(localPos.Y) <= halfSize.Y
and math.abs(localPos.Z) <= halfSize.Z
end
local baseData = {}
local function setupBase(base)
if not base:IsA("Folder") then return end
local nicknamePart = base:FindFirstChild("NicknameAndAvatarPlayer")
if not nicknamePart then return end
local baseZone = nicknamePart:FindFirstChild("BaseZone")
local billboardGui = nicknamePart:FindFirstChildOfClass("BillboardGui")
if not baseZone or not billboardGui then return end
local data = {
base = base,
baseZone = baseZone,
billboardGui = billboardGui,
isInZone = false,
}
table.insert(baseData, data)
end
for _, base in basesFolder:GetChildren() do
setupBase(base)
end
basesFolder.ChildAdded:Connect(function(child)
task.wait(0.5)
setupBase(child)
end)
local RUN_INTERVAL = 0.3
task.spawn(function()
while true do
local character = player.Character
if character then
for _, data in baseData do
local ownerName = getOwnerName(data.base)
if ownerName ~= player.Name then
local wasInZone = data.isInZone
data.isInZone = isInsideZone(character, data.baseZone)
if wasInZone ~= data.isInZone then
setGuiVisible(data.billboardGui, not data.isInZone)
end
end
end
end
task.wait(RUN_INTERVAL)
end
end)