GUI object positioning according to another GUI object

  1. What do you want to achieve?
    I am trying to make a cool overhead nametag system for players by adding their username with a custom textlabel that has a imagelabel before the textlabel (like: [ICON] Username), to have device icons or premium icons or group rank icons, and I basically cant really do the position code, I already have the sizing code, but I just need a little bit of help with the positioning of the frame…(ive been always bad with math)

  2. What is the issue?
    i cant position properly the frame before the textlabel (read above for more info)

  3. What solutions have you tried so far?
    I tried looking on the devforum for solutions (i am bad at math so i couldnt really fix it)

This is the code im currently using:

local Tip = script.Parent:WaitForChild("TextLabel")
local Frame = script.Parent:WaitForChild("Frame")

local minWidth, minHeight = 3, 3

Tip:GetPropertyChangedSignal("TextBounds"):Connect(function()
	Tip.Size = UDim2.new(0, math.max(minWidth, Tip.TextBounds.X), 0, 50)
	
	-- frame should position here
end)

You may not even need code in order to do this:

  • Have the textlabel take up only part of a frame that contains it.
  • Then, add a UIListLayout to the frame.
  • Set the LayoutOrder of the TextLabel to something like 10.
  • Have the icons have a layout order of less than 10.
  • Parent the icons to the frame containing the textlabel and they should appear before the textlabel
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.