# How to make a stage progress

I want to make a progress showing how far I am away from next level.

Example: If I am in the middle of the obby it would be half way to the next stage (this isn’t a stage progress) like 1/20 stages completed it’s for 1 stage and once you complete it goes to the next one

1. You can get the magnitude of the end node of the stage to the start node of the stage (call this totalDistance)
2. You can get the player’s magnitude from the starting node of the stage (call this playerDistance)
3. You can divide the playerDistance by the totalDistance (call this progressPercent)
4. Set the scalarX of the frame to progressPercent.

Note: When you divide the playerDistance by the totalDistance, this will give you a percent of the way that the player is from the end node, which can be used on the gui.

I know this seems a little confusing, so let me know if this makes sense!

1 Like

would i need to create 2 dif parts?

You would need a part at the beginning of the stage (start node), and a part at the end of the stage (end node). So yes

wdym by node? also how would that work since the parts could be any distance apart like 30 or 70

Let’s say the distance between the start node and end node is 30 and the player’s distance from the start node is 10.

We can divide the distance from the start node by the total distance:

10 / 30 = 0.333.

This means we are 1/3 of the distance to end node, which makes sense.
frame.Size = UDim2.new(percentProgress, 0, scalarY, 0)

Also, check my original reply because I edited it to make this much easier.

The start node is a part that represents the starting position. The end node is a part that represents the ending position.

could you please show me an example i dont really understand

Here’s some code I wrote with a video demonstration. Please don’t use while loops like this in your code. Instead, use an event that fires when the character position updates.

``````local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:wait()
local hrp = char:WaitForChild("HumanoidRootPart")

local frame = script.Parent

local endNode = workspace:WaitForChild("EndNode")
local startNode = workspace:WaitForChild("StartNode")

local totalDistance = (endNode.Position - startNode.Position).Magnitude

while true do
local playerDistance = (hrp.Position - startNode.Position).Magnitude
local progressPercent = playerDistance / totalDistance
frame.Size = UDim2.new(progressPercent, 0, 1, 0)
task.wait()
end
``````

robloxapp-20210816-1154209.wmv (3.6 MB)

1 Like

Just tested it and it works but when i go farther away from the start it increases and when i go left or right it increases

Magnitude is inaccurate as it would calculate the 3 axises therefore if you fell while not walking it would seem like you were going backwards.