Teleporting after buying a developer pass

I have a developer pass that allows a player to skip a stage however i’m not sure how to make the player teleport to the next stage. The leaderstats value changes but the player needs to reset character to be placed at the next stage. I want them to automatically be placed at the next one. I’m not the best at scripting and am still learning.

ServerScript:

local MarketPlaceService = game:GetService("MarketplaceService")
local product = 1351152540


local function processReceipt(receiptInfo)
	if receiptInfo.ProductId == product then
		local player = game:GetService("Players"):GetPlayerByUserId(receiptInfo.PlayerId)
		if not player then
			return Enum.ProductPurchaseDecision.NotProcessedYet
		end
		
		player.leaderstats.Stage.Value = player.leaderstats.Stage.Value + 1

    -- how to make them teleport here?

		return Enum.ProductPurchaseDecision.PurchaseGranted	
	end
end
MarketPlaceService.ProcessReceipt = processReceipt

I think this is what youre talking about

player.Character:MoveTo(Checkpoints[player.leaderstats.Stage.Value].Position)
player.Character:PivotTo(Checkpoints[player.leaderstats.Stage.Value].CFrame)
player.Character.HumanoidRootPart.Position = Checkpoints[player.leaderstats.Stage.Value].Position

I get the error: ServerScriptService.SkipStage:14: attempt to index nil with number

Also it says: unknown global ‘Checkpoints’. Not sure what to do next.

Script:

local MarketPlaceService = game:GetService("MarketplaceService")
local product = 1351152540


local function processReceipt(receiptInfo)
	if receiptInfo.ProductId == product then
		local player = game:GetService("Players"):GetPlayerByUserId(receiptInfo.PlayerId)
		if not player then
			return Enum.ProductPurchaseDecision.NotProcessedYet
		end
		
		player.leaderstats.Stage.Value = player.leaderstats.Stage.Value + 1
		
		player.Character:MoveTo(Checkpoints[player.leaderstats.Stage.Value].Position)
		
		return Enum.ProductPurchaseDecision.PurchaseGranted	
	end
end
MarketPlaceService.ProcessReceipt = processReceipt

How are you storing your Checkpoints?

Replace Checkpoints with what you are storing it with

The Code will error if the Object doesnt exist or mispelled

This is a very easy thing to solve, I’m not sure how you are confused, this is a very basic thing you should know.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.