Obby skip stage script help

Hey Developers!
So I’m having some trouble with one of my scripts for one of my games. It’s something to do with gui’s. I want the player to have 3 skips, but when they use up all of their skips, and they click the ‘Skip Stage’ button, I want my developer product to pop up saying ‘Buy +1 Skip!’ and when they buy it, they get that amount of skips added to the skip stage button. Right now, the problem is that the buttons aren’t doing anything. I try to click ‘Skip Stage (3)’ but it won’t take me to the next checkpoint. Anything that I’m doing wrong?
Skip Stage script:

-- local MarketplaceService = game:GetService("MarketplaceService")
local GamepassID = 9950329
local player = game.Players.LocalPlayer
local leaderstats = player:WaitForChild("leaderstats"):FindFirstChild("Stage")
local hasLimits = true
local Limits = 3

script.Parent.MouseButton1Click:Connect(function()
	if MarketplaceService:UserOwnsGamePassAsync(player, GamepassID) then
    if hasLimits == true then
        if Limits ~= 0 then
            Limits = Limits - 1
            script.Parent.Text = "Skip Stage ("..Limits..")"
            leaderstats.Value = leaderstats.Value + 1
            if player ~= nil then
                if player.Character ~= nil then
                    if player.Character:FindFirstChild("Humanoid").Health > 0 then
                        player.Character.HumanoidRootPart.CFrame = game.Workspace:FindFirstChild(leaderstats.Value).CFrame + Vector3.new(0,3,0)
                    end
                end
            end
        end
    else
		MarketplaceService:PromptGamePassPurchase(GamepassID)
	end
end)	
		
			
				
					
						
							
								
									
										
											
			if hasLimits == true then
			if Limits ~= 0 then
				Limits = Limits - 1
				script.Parent.Text = "Skip Stage ("..Limits..")"
				leaderstats.Value = leaderstats.Value + 1
            	if player ~= nil then
              		if player.Character ~= nil then
                   		if player.Character:FindFirstChild("Humanoid").Health > 0 then
                   player.Character.HumanoidRootPart.CFrame = game.Workspace:FindFirstChild(leaderstats.Value).CFrame + Vector3.new(0,3,0)
				end
			end
		end
	end		
end)
	

Buy +1 Skip script (I don’t want this)

local player = game.Players.LocalPlayer
local leaderstats = player:WaitForChild("leaderstats"):FindFirstChild("Stage") -- Change Stage to your Stats
local hasLimits = true
local Limits = 3
 
script.Parent.MouseButton1Click:connect(function(player, id)
    if hasLimits == true then
        if Limits ~= 0 then
            Limits = Limits - 1
            script.Parent.Text = "Skip Stage ("..Limits..")"
            leaderstats.Value = leaderstats.Value + 1
            if player ~= nil then
                if player.Character ~= nil then
                    if player.Character:FindFirstChild("Humanoid").Health > 0 then
                        player.Character.HumanoidRootPart.CFrame = game.Workspace:FindFirstChild(leaderstats.Value).CFrame + Vector3.new(0,3,0)
                    end
                end
            end
        end
    else
        if player ~= nil then
            if player.Character ~= nil then
                if player.Character:FindFirstChild("Humanoid").Health > 0 then
                    player.Character.HumanoidRootPart.CFrame = game.Workspace:FindFirstChild(leaderstats.Value).CFrame + Vector3.new(0,3,0)
                end
            end
        end
    end
end)

Any advice would be greatly appreciated!

2 Likes

What type of script are you using? Are there any errors? Another good way to debug this is after every if statement have a print statement. For example:

script.Parent.MouseButton1Click:Connect(function()
print("clicked")
if MarketplaceService:UserOwnsGamePassAsync(player, GamepassID) then
print("owns gamepass")
    if hasLimits == true then
print("hasLimits")
        if Limits ~= 0 then
print("limits doesn't equal 0")
            Limits = Limits - 1
            script.Parent.Text = "Skip Stage ("..Limits..")"
            leaderstats.Value = leaderstats.Value + 1
            if player ~= nil then
print("ect")
                if player.Character ~= nil then
print("ect")
                    if player.Character:FindFirstChild("Humanoid").Health > 0 then
                        player.Character.HumanoidRootPart.CFrame = game.Workspace:FindFirstChild(leaderstats.Value).CFrame + Vector3.new(0,3,0)
                    end
                end
            end
        end
    else
		MarketplaceService:PromptGamePassPurchase(GamepassID)
	end
end)	

This way you know what works and doesn’t work. Also I noticed an error in the skip stage script towards the bottom.

			if hasLimits == true then
			if Limits ~= 0 then
				Limits = Limits - 1
				script.Parent.Text = "Skip Stage ("..Limits..")"
				leaderstats.Value = leaderstats.Value + 1
            	if player ~= nil then
              		if player.Character ~= nil then
                   		if player.Character:FindFirstChild("Humanoid").Health > 0 then
                   player.Character.HumanoidRootPart.CFrame = game.Workspace:FindFirstChild(leaderstats.Value).CFrame + Vector3.new(0,3,0)
				end
			end
		end
	end		
end) --here

just get rid of that parenthese.

So just try adding print statements to see which line of code isn’t working. Hope this helped! Have a good day!

3 Likes

I will try this. I’ll let you know if this has helped. Thanks!
Edit: I am using LocalScripts for both scripts.

3 Likes