#2d camera. Billboard gui dissapearing.

1 messages · Page 1 of 1 (latest)

hoary mulch
#

So i have an 2d camera system that works fine. But then i added a billboardgui on an ai thats moving and it dissapears after like 50 studs.

But then i tried disabling the camera scripts and it worked. The gui did not dissapear

So do anyone have a solution to this?
the script handling the 2d camera looks like this

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")

local player = Players.LocalPlayer
local camera = workspace.CurrentCamera

camera.CameraType = Enum.CameraType.Scriptable

RunService.RenderStepped:Connect(function()
local character = player.Character
if character and character:FindFirstChild("HumanoidRootPart") then
local root = character.HumanoidRootPart
local topDownPosition = root.Position + Vector3.new(0, 50, 0) -- height of camera
local lookAt = root.Position

    camera.CFrame = CFrame.new(topDownPosition, lookAt)
end

end)

#

Ive done alot of debugging

#

and nothing works

#

i figured out its has to do something with the script

#

but idk what

#

and i need to keep the script

glacial matrix
#

There will be a property called viewing distance

hoary mulch
shrewd sigilBOT
#

studio** You are now Level 1! **studio

glacial matrix
#

Or similar

glacial matrix
hoary mulch
#

uh

#

i can send you the properties of the billboard

glacial matrix
#

Yes please

hoary mulch
glacial matrix
#

Like

#

The text properties

hoary mulch
#

text?

glacial matrix
#

Yeah

#

Or whatever

hoary mulch
#

wdym

glacial matrix
#

Whats it showing

#

Show me the children of the billboard

hoary mulch
#

2 frames

glacial matrix
hoary mulch
#

just color

#

its an health bar

glacial matrix
#

Show me the top frame property please

hoary mulch
glacial matrix
#

Found it

hoary mulch
#

wait fr?

glacial matrix
#

-- In your BillboardGui setup:
billboardGui.AlwaysOnTop = true

#

If that doesn’t work

#

Use Camera:WorldToViewportPoint() to determine if the AI is in view, and then enabling/disabling the BillboardGui manually.

hoary mulch
#

my billboard gui has had always on top for ages

#

it was the 2nd thing i tried

glacial matrix
hoary mulch
#

now it got complicated here 😭

#

how do i do allat?

glacial matrix
#

Basically frustum culling on roblox is stupid

hoary mulch
#

bro what

#

im not THAT good at roblox studio

#

sorry

#

can you explain it more begginer friendly?

glacial matrix
#

Sure

#

1 sec

glacial matrix
#

As it’s not connected to a camera object

#

It’s freaks out

hoary mulch
#

uh okay

#

and how do i fix that?

glacial matrix
#

local RunService = game:GetService("RunService")
local camera = workspace.CurrentCamera

-- Reference your AI and its BillboardGui
local ai = workspace:WaitForChild("YourAI") -- replace with your actual AI
local gui = ai:WaitForChild("BillboardGui") -- make sure this is correct

RunService.RenderStepped:Connect(function()
if ai and ai:FindFirstChild("HumanoidRootPart") then
local screenPoint, onScreen = camera:WorldToViewportPoint(ai.HumanoidRootPart.Position)

    -- Toggle GUI visibility manually
    gui.Enabled = onScreen
end

end)

#

Try that

#

In SS

#

(Starter player)

hoary mulch
#

okay

#

wait should i make a new starter player script or replace the camera one i already have?

glacial matrix
#

If that doesn’t work I’ll implement into your current script

hoary mulch
#

ok

glacial matrix
#

But it won’t work as well

hoary mulch
shrewd sigilBOT
#

studio** You are now Level 2! **studio

hoary mulch
#

ive tried everything for over 2 hours 😭

glacial matrix
#

1 second

hoary mulch
glacial matrix
#

Delete that script

#

The one

#

I sent

hoary mulch
#

yeah its disabled

glacial matrix
hoary mulch
glacial matrix
#

And

#

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")

local player = Players.LocalPlayer
local camera = workspace.CurrentCamera

camera.CameraType = Enum.CameraType.Scriptable

RunService.RenderStepped:Connect(function()
local character = player.Character
if character and character:FindFirstChild("HumanoidRootPart") then
local root = character.HumanoidRootPart

    -- Adjust camera height and rotation
    local cameraHeight = 50
    local cameraOffset = Vector3.new(0, cameraHeight, 0)
    local topDownPosition = root.Position + cameraOffset
    local lookDirection = Vector3.new(0, -1, 0) -- Looking straight down

    -- Look slightly *diagonally* instead of straight down to help BillboardGuis render
    local epsilon = 0.001
    local adjustedLook = root.Position + Vector3.new(epsilon, -1, epsilon)

    camera.CFrame = CFrame.new(topDownPosition, adjustedLook)
end

end)

#

Change your script to that

hoary mulch
#

okay

#

it still doesnt work

#

idfk what to do 😭

glacial matrix
#

Yeah you’ve lost me there

#

Sorry

hoary mulch
#

ive asked multipe ppl and multiple ais and ive got no solution

hoary mulch
#

well atleast you tried

#

well do you know any way for me to debug even more? @glacial matrix

glacial matrix
#

Sorry

hoary mulch
#

yeah its fine

glacial matrix
#

I’m sleeping now

#

Nighty night

hoary mulch
#

good night

hoary mulch
#

@river nebula

hoary mulch
#

bro @river nebula ik youre there 😭

last latch
#

@hoary mulch

#

record it

hoary mulch
#

record what?

last latch
#

your camera

#

your silly game

#

record it

hoary mulch
#

😭

#

okay

last latch
#

and show me

#

im not reading all that script to make sure it works or not

hoary mulch
#

so it works perfectly fine when the cam script is of

#

there is 32 lines of code ruining it

last latch
#

okay

#

hold on

#

let me open

#

studio

hoary mulch
#

dont

last latch
#

?

hoary mulch
#

@river nebula solved it

#

idk how though

last latch
#

just right now? or what

#

well okay

river nebula
last latch
river nebula
#

so i just threw it into the renderstepped function

last latch
#

oh

#

thats why