Hello, I am using Shnerpy’s Obby Kit, and I am trying to make it so if I am on stage 100 and select 90 and later touch the 91 checkpoint, my number on the stage transfer will be changed to 91. However, with my implementation, if you spam the back button it sometimes glitches out a bit and sets the stage back to original (before clicking back button). Is there any way to prevent this completely?
Code for checkpoints (modified from original script in model)
for _, v in pairs(workspace.Checkpoints:GetChildren()) do
v.Touched:Connect(function(hit)
if v ~= nil then
if v.Parent == workspace.Checkpoints then
local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
if player then
if player.leaderstats.Stage.Value == tonumber(v.Name) - 1 then
player.leaderstats.Stage.Value += 1
player.TeleportedStage.Value = player.leaderstats.Stage.Value
elseif player.TeleportedStage.Value == tonumber(v.Name)-1 then
plr.TeleportedStage.Value = tonumber(v.Name)
end
end
end
end
end)
end
Video: https://gyazo.com/77ca8b9207a958819eb831a51fdd2557
Thanks!