Make a GUI lock to the player head

So I Am trying to make a Military gun game. And I want the Ammo text to be besides the Characters head.

How do I make it without just having the gui locked in the center of the screen whatever because if the camera moves it gets weird.

You could place a brick into the character (next to the head or desired spot you want the ammo text to show) and have a surface gui adornee the part (Put the ammo info in the surface gui).

I have tried with Welding but I have not worked so much with it, so how do I change the position of the part as it’s in the middle of the head.

Have you tried a billboard gui with a certain XYZ Offset? I think that would be the most practical scenario.

1 Like

Er? Guis don’t lock at the center of the screen. ScreenGuis are applied to the screen in 2D space, SurfaceGuis are applied to a surface in 2D space, BillboardGuis are in 3D space. I’m not sure what you’re doing to achieve this supposed weird behaviour.


You have two options; an offset BillboardGui or a part with a ScreenGui welded to the Character’s head and offset by some.

I’m not very good at coding but I made this as a sort of template of what you’re looking for

Inside a LocalScript

local plr = game.Players.LocalPlayer
local char = plr.Character
wait(2)
local part = Instance.new('Part', char)
part.CanCollide = false
part.Anchored = true

local ammogui = Instance.new("SurfaceGui", part)
ammogui.Face = 'Back'
local ammotext = Instance.new("TextLabel",ammogui)
ammotext.Size = UDim2.new(1,0,1,0)
ammotext.Text = '30/100'
ammotext.TextScaled = true
ammotext.BackgroundTransparency = 1
ammotext.Font = Enum.Font.Code
ammotext.TextColor3 = Color3.fromRGB(255,255,255)

part.Size = Vector3.new(2.45, 1.15, 0.45)
local direction = CFrame.new(part.Position, char['HumanoidRootPart'].Position).lookVector
local increment = direction

while wait() do
	part.CFrame = char['HumanoidRootPart'].CFrame * CFrame.new(3,3,0)
	--part.Rotation = char['HumanoidRootPart'].Rotation + (direction * increment) + Vector3.new(0,-7,0)
end

It’s very choppy, again I’m not good at it but you get an idea

surface gui? billboard gui?? i don’t really understand much what ur trying to do here

You’re definitely looking for a Billboard Gui.

Take a look at the documentation for it.

https://developer.roblox.com/api-reference/function/Camera/WorldToScreenPoint

It would be nice if you explained the relevance of this article or provided a sample of something, rather than just posting an article and expecting people will know what to do with this.

I’m also not sure how this is relevant to the OP? They’re trying to make an ammo counter beside a character’s head. This is different from what they’re asking for.

1 Like

They want to place TextLabel or whatever it is next to character head. First get character heads position to screen point and change the Element’s position with position is it given.

1 Like