Hello! I’ve been working on a difficulty chart obby to test my skills, but there’s something wrong with the stage selector. I want the player to be able to select stages easily. However, the stages will ‘skip’ using the selector. I’ve tried renaming the parts used, but it always breaks after a day! However, there is something very important here. I have a friend who helps me test, and for some reason it doesn’t break on his end! Here’s the code I use to handle the checkpoints when they are touched:
local checkpoints = workspace:WaitForChild("Checkpoints")
print("| Pixel's Checkpoint System Initalized |")
for i,v in pairs(checkpoints:GetChildren()) do
if v:IsA("BasePart") then
v.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if tonumber(v.Name) > player.leaderstats.Checkpoint.Value then
player.leaderstats.Checkpoint.Value = tonumber(v.Name)
end
end
end)
end
end
and what I use for the stage selector:
local UI = script.Parent
local player = game.Players.LocalPlayer
local checkpoints = workspace:WaitForChild("Checkpoints")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Teleport = ReplicatedStorage:WaitForChild("Teleport")
local Counter = UI:WaitForChild("Counter")
local Level = Counter:WaitForChild("Level")
local Previous = UI:WaitForChild("Previous")
local Next = UI:WaitForChild("Next")
local CurrentValue = UI:WaitForChild("Current")
local function previousLevel()
if CurrentValue.Value ~= 1 then
CurrentValue.Value = CurrentValue.Value - 1
Level.Text = CurrentValue.Value
-- teleport
Teleport:FireServer(checkpoints:GetChildren()[CurrentValue.Value])
end
end
local function nextLevel()
if CurrentValue.Value ~= #checkpoints:GetChildren() then
if (CurrentValue.Value + 1) <= player.leaderstats.Checkpoint.Value then
CurrentValue.Value = CurrentValue.Value + 1
Level.Text = CurrentValue.Value
-- teleport
Teleport:FireServer(checkpoints:GetChildren()[CurrentValue.Value])
end
end
end
Previous.MouseButton1Click:Connect(function()
previousLevel()
end)
Next.MouseButton1Click:Connect(function()
nextLevel()
end)
-- setup Level
CurrentValue.Value = player:WaitForChild("leaderstats").Checkpoint.Value
Level.Text = CurrentValue.Value
player.leaderstats.Checkpoint:GetPropertyChangedSignal("Value"):Connect(function()
CurrentValue.Value = player.leaderstats.Checkpoint.Value
Level.Text = CurrentValue.Value
end)
NOTE: You must know that these scripts are borrowed from Pixel’s Difficulty Chart Obby Kit.
Thanks!