Distance from Object

Goal: Instead of Y (up/down) I need it z(left/right), the issue is when I try to change Y to x it doesn’t work.

Code so far:

How would I make this instead of going up and down to going left and right?
local bar = script.Parent

local heightTemplate = script:WaitForChild("PlayerHeight")


local goingUp = false


local maxHeight = workspace.HeightPart.Size.Y
local minHeight = 0

local heightDifference = maxHeight - minHeight


local increments = 1 / heightDifference



game:GetService("RunService").RenderStepped:Connect(function()
	
	
	for i, child in pairs(bar:GetChildren()) do
		
		if child:IsA("Frame") then child:Destroy() end
	end
	
	
	for i, plr in pairs(game.Players:GetPlayers()) do


		local heightIndicator = heightTemplate:Clone()

		local plrImage = game.Players:GetUserThumbnailAsync(plr.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
		heightIndicator.PlayerImage.Image = plrImage

		heightIndicator.Parent = bar


		local char = plr.Character or plr.CharacterAdded:Wait()
		local hrp = char:WaitForChild("HumanoidRootPart")
			

		local yHeight = math.clamp(hrp.Position.Y, minHeight, maxHeight)
			
		local yPos

		if goingUp then
			yPos = yHeight * increments

		else
			yPos = (maxHeight - yHeight) * increments
		end
		
		heightIndicator.Position = UDim2.new(heightIndicator.Position.X.Scale, heightIndicator.Position.X.Offset, yPos, 0)
	end
end)

This doesnt explain anything. You’ve just pasted code and all thats left to look at is the title.

Please elaborate on what your code is supposed to do and what you want it to do and what exactly it isnt doing (you already explained the last part)

It’s a race clicker progress bar,

It shows the user’s progression to the end part.

UDim2.new(XScale, XOffset, YScale, YOffset)
These are the parameters that UDim2 accepts. Are you sure you’re putting the right parameters in the right place?

I think, could you help me fix it?

heightIndicator.Position = UDim2.new(0, yPos, heightIndicator.Position.Y.Scale, heightIndicator.Position.Y.Offset)

Didn’t do anything. oof.

(the limit for characters)

Do you want the player’s Y position to be fixed, or your GUI’s Y position?

I just need it to work. Both if possible.