Pay for checkpoint

Hey, so basically i want to make a checkpoint in my game were when you walk over it a game pass comes up asking if you want to buy the checkpoint. If you do then the checkpoint saves your location. Please help ASAP as my launch is already delayed.
Much appreciated!

2 Likes

My bad, forgot to script the Buy part.

ServerScriptService: Script

local marketplace = game:GetService("MarketplaceService")

local gamepassid = 000000000 --add your gamepass id here

local players = game.Players

local checkpoint = workspace.CheckPoint --Replace this with your checkpoint you want the player to spawn in if they bought the gamepass.

players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		if marketplace:UserOwnsGamePassAsync(plr.UserId, gamepassid) then
			char:SetPrimaryPartCFrame(checkpoint.CFrame)
		end
	end)
end)

Inside your payed checkpoint: Script

local marketplace = game:GetService("MarketplaceService")
local checkpoint = script.Parent

local gamepassid = 000000000 --add your gamepass id here

checkpoint.Touched:Connect(function(hit)
	if game.Players:GetPlayerFromCharacter(hit.Parent) then
		local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
		marketplace:PromptPurchase(plr, gamepassid)
	end
end)
1 Like