Trying to make sliding square minigame, can't figure out how to adjust a GUI position

Hi, I’m trying to make a script to move a square on a slider. The goal is that when the player clicks on a sweet spot, and if the square is in that sweet spot, the score increases and the speed of the square’s sliding increases.

However, I’ve ran into issues translating what I know about moving things to GUIs. I’ve tried exchanging all of the below Position.X with a Position.Width or Position.Width.Offset, but I really don’t understand UDims. How would I go about adjusting a GUI’s position given this structure to make it move left and right on the slider?

In the workspace, my structure is
qualitygame

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local QualityGameStartEvent = ReplicatedStorage.events.QualityGameStart
local QualityGameEndEvent = ReplicatedStorage.events.QualityGameEnd
local sliding_cube = script.Parent
local slider_bar = script.Parent.Parent
local target = script.Parent.Parent.Target
local quality = 0
local speed = 5
local gameOver = false

local function skipQualityGame()
	QualityGameEndEvent:FireServer(1)
end

local function startQualityGame()
	local moveDirection = false -- False is left true is right
	local position = slider_bar.Position.X
	local min_x = slider_bar.Position.X - slider_bar.Size.X / 2
	local max_x  = slider_bar.Position.X + slider_bar.Size.X / 2
	while gameOver == false do
		if moveDirection == false then
			position = position + speed
			sliding_cube.Position.X = position
			if position > max_x then
				moveDirection = true
			end
			wait(0.1)
		else
			position = position - speed
			sliding_cube.Position.X = position
			if position < min_x then
				moveDirection = false
			end
			wait(0.1)
		end
	end
	QualityGameEndEvent:FireServer(quality)
end

local function checkValid()
	local position = sliding_cube.Position.X
	local target_x_min = target.Position.X - target.Size.X / 2
	local target_x_max = target.Position.X + target.Size.X / 2
	local min_x = slider_bar.Position.X - slider_bar.Size.X / 2
	local max_x  = slider_bar.Position.X + slider_bar.Size.X / 2
	if position < target_x_max and position > target_x_min then
		quality = quality + 0.1
		speed = speed * 1.2
		sliding_cube.Position.X = math.random(min_x + sliding_cube.Size.X / 2,max_x - sliding_cube.Size.X / 2)
	else
		gameOver = true
	end
end

QualityGameStartEvent.OnClientEvent:Connect(startQualityGame)
target.MouseButton1Up:Connect(checkValid)

Use TweenService to animate gui from one position to the other