Is there a better way to set a text label to a parts location?

I’m making a lot of things in my game show up when you go near them, and you press “E” or such. The problem is shown in the video below, Its very laggy when you move your camera around the block when you are near it. Basically for the script I’m doing

TextLabel.Position= game.Workspace.Door.Center

The issue shown in the video below is that its too laggy and glitchy, and in Jailbreak for example its very clean even when you move your camera around the text label.

video isn’t uploading sorry …

I haven’t tried much solutions as I don’t know a better way to do this.

Here is the local script making the text label visible when you near the block or door.

local PlayerService = game:GetService('Players')
local UserInputService = game:GetService('UserInputService')
local Door = workspace.ElementDoor.Door
--< Variables
local Player = PlayerService.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:wait()

local PlayerGui = Player:WaitForChild('PlayerGui')

local GameGui = PlayerGui:WaitForChild('GameGui')
local Text = GameGui.ImageLabel

local Activ = false
local Obj = nil

--< Events
UserInputService.InputBegan:Connect(function(Input)
	if Activ and Input.UserInputType == Enum.UserInputType.Keyboard and Input.KeyCode == Enum.KeyCode.E then
		Obj.Config.DetectEvent:FireServer()
	end
end)

--< Loops
while wait() do
	Obj = nil
	Activ = false
	Text.Visible = false
	for _, Door in pairs(workspace.ElementDoor:GetChildren()) do
		local mag = (Character.HumanoidRootPart.Position - Door.Center.Position).magnitude
		if mag <= Door.Config.Range.Value then
			local D3ToD2 = workspace.CurrentCamera:WorldToScreenPoint(Door.Center.Position)
			Text.Visible = true
			Text.Position = UDim2.new(0,D3ToD2.X,0,D3ToD2.Y,0)
			Activ = true
			Obj = Door
		end
	end
end ```

Also the line of code making the Text visible and changes its position is at line 34 and 35.
1 Like

Do you mean when you get close to a part, it displays that “Press e to do something”?

If so, I’m pretty sure you can just use billboard guis, there isn’t a need for having to manually have a textlabel on the screen position relative to the part.

EDIT: You would of course have to do magnitude checks as normal, adorne (i think) to the part to see/position it. Then do your “press e” functions and stuff.

1 Like