#Stage Selector help

1 messages · Page 1 of 1 (latest)

elder radish
#

so i made a stage selector and it works before but after creating 1-50 checkpoints it wont work anymore it only works on 1-40 checkpoints

elder radish
# elder radish so i made a stage selector and it works before but after creating 1-50 checkpoin...

local plr = game.Players.LocalPlayer
local checkpoints = workspace:WaitForChild("Checkpoints")
local frame = script.Parent

local function getMaxStage()
return #checkpoints:GetChildren()
end

local function teleportToStage(stageNumber)
local checkpoint = checkpoints:FindFirstChild(tostring(stageNumber))
if checkpoint and plr.Character and plr.Character:FindFirstChild("HumanoidRootPart") then
local pos = checkpoint.Position
plr.Character.HumanoidRootPart.CFrame = CFrame.new(pos.X, pos.Y + 5, pos.Z)
end
end

local function updateTempStage(delta)
local leaderstats = plr:FindFirstChild("leaderstats")
local tempStage = plr:FindFirstChild("tempStage")
if not leaderstats or not tempStage then return end

local current = tempStage.Value
local maxUnlocked = leaderstats:FindFirstChild("Stage") and leaderstats.Stage.Value or 1
local target = current + delta

if target >= 1 and target <= math.min(maxUnlocked, getMaxStage()) then
    tempStage.Value = target
    teleportToStage(target)
else
    warn("Cannot move to stage " .. tostring(target))
end

end

frame.B1.MouseButton1Down:Connect(function()
updateTempStage(-1)
end)

frame.B10.MouseButton1Down:Connect(function()
updateTempStage(-10)
end)

frame.F1.MouseButton1Down:Connect(function()
updateTempStage(1)
end)

frame.F10.MouseButton1Down:Connect(function()
updateTempStage(10)
end) (heres the script im using)