How can I make this dot tween left to right based on player position (video example included)

I’m trying to get a dot to tween to a player’s X position, but also max out after a certain distance. For example, the dot’s max coordinates will be X -200 to X 200. If the player’s X coordinate is within this range, the dot will tween across the screen in a progress-bar like fashion. If they are outside this coordinate range, the dot will max out before the end of the screen.

Here is a video example of what I mean:

Here is my code so far:

local dot = script.Parent

		local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
		local pos =, 0, 0.05, 0)
		while humanoidRootPart do
1 Like

So you need something like Tower of Hell or i’m understaning wrong?

YEA! exactly! I hadn’t thought of that. Thanks!

I think you need to calculate the distance from end part. Here, i think this should help you!

But how do I incorporate this into tweening the gui location?

Exactly, basing the distance - actual distance = how much distance is left and you can do like

if distance is 200 (start to end) -ActualDistance = 20 then you are at 10% and you can move the dot of 10% of the screen

1 Like

Something like this Could help:

Also those are for height and you are searching for orizontal bar, so need to change something.

Luckily for you, there’s WorldToScreenPoint which converts a Vector3 world position to a Vector3 screen point (X and Y represent X, Y positions). This can be clamped with the math.clamp() function to fit it in your -200 to 200 range.

You’ll want to wait on the LocalPlayer’s Character to spawn (this needs to be a LocalScript), and then update the dot on Stepped which is a less-blocking event that fires about every frame.


local RunService = game:GetService("RunService");
local Players = game:GetService("Players");

local player = Players.LocalPlayer;
local character = player.Character or player.CharacterAdded:Wait();

local camera = workspace.CurrentCamera;
local dot = script.Parent;

local function update_character(new_character)
    character = new_character; --// Update the character variable to yhe newly spawned

local function update_dot()
    local root = character and character:FindFirstChild("HumanoidRootPart");

    if (root) then --// Ensure there is a HumanoidRootPart
        local position, _, on_screen = Camera:WorldToScreenPoint(root.Position);

        if (on_screen) then
            dot.Position =, math.clamp(position.X, -200, 200), 0, 0);



Nothing happens? :thinking:

I don’t think he’s trying to do it by literal position, instead by how far a player is on a start-end basis.

1 Like

Try this:

local startPos = (startblock).Position
local endPos = (endblock).Position
local character = character argument here
local totalDistance = (startPos - endPos).magnitude
local RunService = game:GetService("RunService")

	--// Reusing Returned's code:
	local root = character and character:FindFirstChild("HumanoidRootPart");
	if (root) then --// Ensure there is a HumanoidRootPart
		local Distance = (root.Position - startPos).magnitude
		local distanceDivided = Distance / totalDistance
		-- Tween the dot using DistanceDivided as the X Scale argument


You replace those with your own blocks, assuming that there’s a start block and a finish block.

Do you think something like this?

1 Like

YES! this is PERFECT! Exactly what I meant.

p.s. I love the bandicam watermark lol haven’t seen that in a while

1 Like

How do you create this? Was this made with the previous code?

No, i coded it myself, but the principle is the same.

Here! That will be 100 robux! jk, take it for free!
starttoend.rbxl (29.7 KB) FIXED!

And for that people that want to know if this is a virus:

i mean why would i add a virus :smiley:

1 Like

You had me for a moment…

Thank you so much!

1 Like

Uh I just noticed that if you walk behind the start block, the dot starts tweening again. Any idea how to stop this?