I know there’s such thing as a billboard ui so I can properly add a textlabel into a part and it pops up. But what if I wanted to make a ui on my screen, that positions the text to a part’s position?
2 Likes
Use Camera:WorldToScreenPoint
(or, if the ancestor ScreenGui’s IgnoreGuiInset is enabled, Camera:WorldToViewportPoint
. Every render step, get the screen point from the world position of the part and set the text label’s position to that point.
local runService = game:GetService("RunService")
local camera = workspace.CurrentCamera
local textLabel = path.to.text.label
local part = path.to.part
runService:BindToRenderStep("FollowWorldPosition", Enum.RenderPriority.Last.Value, function(deltaTime)
local screenPoint, isInBounds = camera:WorldToScreenPoint(part.Position)
if not isInBounds then
textLabel.Visible = false
return
end
textLabel.Visible = true
textLabel.Position = UDim2.new(0, screenPoint.X, 0, screenPoint.Y)
end)
11 Likes
thanks buddy i appreciate your help!