My title basically says everything im trying to do.
Im trying to make a progress bar on a obby this is the code right now
the issue is the bar resets when the player gets to the next stage
function Stage:CALC(num, char: Model)
local primary = char.PrimaryPart
if (primary) then
local pos_1 = (primary.Position)
local current_pos = (stageNodes:FindFirstChild(num))
if (current_pos) then
local p0 = current_pos.Position
local p1 = (stageNodes:FindFirstChild(num + 1).Position)
local fullDistance = (p0 - p1).Magnitude
local difference = fullDistance - (primary.Position - p1).Magnitude
local percentage = math.clamp(difference / fullDistance, 0, 1)
return percentage
end
end
return 1
end
function Stage:Update()
for player, ui in pairs(self.players) do
local character = player.Character
if (character) then
local leader = player:WaitForChild("leaderstats", 10)
local stage = leader:WaitForChild("Stage", 10)
local stage_calc = (stage.Value / 16)
local difference = self:CALC(stage.Value, character)
local END_CALC = stage_calc * difference
SpringMotion.target(ui, 0.45, 2.5, {
Position = UDim2.new(END_CALC, 0, 1.083, 0)
})
end
end
end