I am currently making an obby and I recently played Master's Difficulty Chart and I saw that they had a system where you can change your stage to a previous stage that you have completed before. After playing the obby, I tried to make it myself. There was one problem when making it, I couldn't get the player to go back to their regular stage or the stage above the one where they teleported to. For example, let's say you are at stage 20 and you click the GUI twice to go back two levels to stage 18. I couldn't script the part where you could go back up to your current stage (in this case, stage 20). I also couldn't script the part where you could go up a level like for example, stage 19. I couldn't script it where you could teleport from stage 8 to stage 19. In addition to that, even though my script did work, It still had some problems. When the player died, they didn't spawn to the stage that they were supposed to spawn in. They still spawned at their current stage. Does anyone how to fix my script and know a solution to how you can save the data from the stages that you have completed and then be able to teleport back to that stage? Help is much appreciated and I thank you for taking your time to read this. My code is shown below.
local plr = game:GetService("Players").LocalPlayer local char = plr.Character local LessStageButton = script.Parent LessStageButton.MouseButton1Click:Connect(function() plr.leaderstats.Stage.Value = plr.leaderstats.Stage.Value - 1 char.Head:Remove() end)