sometimes i get printed 0 sometimes 2 sometimes 1 or a strange numbes, even if i got 3 checkpoints
this problem started today also with another script eith the same issue
local currentLevel = game:GetService("Players").LocalPlayer.leaderstats.Stage
local totalLevels = #game.Workspace:WaitForChild("Checkpoints"):GetChildren()
local progressBar = script.Parent
local tweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(.5, Enum.EasingStyle.Linear)
local levelLabel = script.Parent.Parent.Parent:WaitForChild("Level")
local arrow = script.Parent.Parent.Parent:WaitForChild("Arrow")
local levelString = "Stage "
local endString = "🏆Obby completed!🏆"
print(totalLevels)
progressBar.Size = UDim2.fromScale(1/totalLevels, 1)
arrow.Position = UDim2.fromScale(1/totalLevels, .8)
levelLabel.Text = levelString..currentLevel.Value.." ("..math.round(currentLevel.Value/totalLevels*100).."%)"
currentLevel.Changed:Connect(function()
levelLabel.Text = levelString..currentLevel.Value.." ("..math.round(currentLevel.Value/totalLevels*100).."%)"
local percent = currentLevel.Value/totalLevels
if percent >= 0.05 then
tweenService:Create(progressBar, tweenInfo, {Size = UDim2.fromScale(percent, 1)}):Play()
tweenService:Create(arrow, tweenInfo, {Position = UDim2.fromScale(percent, .8)}):Play()
end
if currentLevel.Value == totalLevels then
wait(tweenInfo.Time)
arrow:Destroy()
wait(.5)
levelLabel.Text = endString
end
end)