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 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