How to create a Finish All button for my obby game?

Im creating an obby game, and I’m trying to create a gamepass button so that when a player purchases this gamepass, they basically teleport to the last checkpoint meaning they finished the game, and on the leaderboard, they are on the last checkpoint, so it obviously isn’t just teleporting to that last checkpoint part. My knowledge on scripting is very limited so I’d appreciate any help. Thanks
(I already have the gamepass made)

You can do this by using a system like this.

local GamePassId = 0


local MarketplaceService = game:GetService("MarketplaceService")


local GamePassPart = workspace.Part



GamePassPart.Touched:Connect(function(Part:BasePart)
	if Part:FindFirstAncestorOfClass("Model") then
		local Character = Part:FindFirstAncestorOfClass("Model")
		
		if Character:FindFirstChildOfClass("Humanoid") then
			for i,v in pairs(game.Players:GetPlayers()) do
				if v.Character == Character then
					MarketplaceService:PromptGamePassPurchase(v,GamePassId)
					-- Your code to manage the gamepass purchase
				end
			end
		end
	end
end)

I have a Checkpoint Model, that includes:

  • Datastores
  • Auto-Setup

here is the link: Model Link

in order to add a skip all game pass follow theses steps:

  1. Insert the model & put the model in ServerScriptService
  2. Open CheckpointSystem>CheckpointSystem_ServerScriptService>CheckpointLeaderstats
  3. at line 108, paste this code:
	local gamepassID = 0

	game:GetService("MarketplaceService").PromptGamePassPurchaseFinished:Connect(function(plr, gpid, p)
		if p and gpid == gamepassID then
			plr["FinishedObby"].Value = true
		end
	end)
  1. Replace gamepassID with your gamepass.

Extra Info:

in order to prompt the player with the game pass, use this code:

game:GetService("MarketplaceService"):PromptGamePassPurchase(PLAYER_HERE, gamepassID)

Replace PLAYER_HERE with the player object,
and replace gamepassID with the gamepass id


how to use the model:

  1. Make sure Lighting has blur in it (set the size to anything you want)
  2. Make sure you have API Services on in order for the datastores to work!!!
  3. in order to add checkpoints, just duplicate the first checkpoint, make sure you duplicate them in the order you want.

If you have any questions about the model please ask

Its not a part that im trying to get the gamepass effect on, it’s a button