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
You can get the magnitude of the end node of the stage to the start node of the stage (call this totalDistance)
You can get the player’s magnitude from the starting node of the stage (call this playerDistance)
You can divide the playerDistance by the totalDistance (call this progressPercent)
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!
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