Skip stage script teleports to place not stated in scirpt

  1. im tryna make a working skip stage that teleports to the next stage from which one the player is on

  2. its teleporting to completely different parts that i did not list at all in the script, i have a folder in workspace with all the parts to keep it organized and lets say i have part 1, part 2 and part 3 in the folder, i set it in the script to teleport to part 1 on buy, i buy it and it teleports to part 3, i rejoin and it teleports to part 2, i rejoin and it teleports to random ones i didnt set

  3. ive tried modifying it from teleporting to coordinates to teleporting to parts but then it just teleports to parts not listed in the script

there are multiple scripts so i will just provide 3, also it happens with every single one and it changes which random one to teleport my character to every time i rejoin

-- Replace this with your Dev Product ID
local devProductId = 1682137093

-- Reference to the Players service
local Players = game:GetService("Players")
local MarketplaceService = game:GetService("MarketplaceService")
local Workspace = game:GetService("Workspace")

-- Define the destination part
local destinationPart = Workspace.SkipStageLocations:WaitForChild("Normal")

-- Function to handle the purchase of the Dev Product
local function onProductPurchase(receipt, player)
	if receipt.ProductId == devProductId then
		local character = player.Character
		if character and destinationPart then
			local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
			if humanoidRootPart then
				humanoidRootPart.CFrame = destinationPart.CFrame
			end
		end
	end
end

-- Function to prompt the purchase
local function promptPurchase(player)
	MarketplaceService:PromptProductPurchase(player, devProductId)
end

-- Connect the onProductPurchase function to the ProcessReceipt callback
MarketplaceService.ProcessReceipt = function(receipt)
	local player = Players:GetPlayerByUserId(receipt.PlayerId)
	if player then
		onProductPurchase(receipt, player)
	end
end

-- Example usage: When a player steps on a part, prompt the purchase
local part = script.Parent

part.Touched:Connect(function(other)
	local player = Players:GetPlayerFromCharacter(other.Parent)
	if player then
		promptPurchase(player)
	end
end)
-- Replace this with your Dev Product ID
local devProductId = 1682137093

-- Reference to the Players service
local Players = game:GetService("Players")
local MarketplaceService = game:GetService("MarketplaceService")
local Workspace = game:GetService("Workspace")

-- Define the destination part
local destinationPart = Workspace.SkipStageLocations:WaitForChild("Hard")

-- Function to handle the purchase of the Dev Product
local function onProductPurchase(receipt, player)
	if receipt.ProductId == devProductId then
		local character = player.Character
		if character and destinationPart then
			local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
			if humanoidRootPart then
				humanoidRootPart.CFrame = destinationPart.CFrame
			end
		end
	end
end

-- Function to prompt the purchase
local function promptPurchase(player)
	MarketplaceService:PromptProductPurchase(player, devProductId)
end

-- Connect the onProductPurchase function to the ProcessReceipt callback
MarketplaceService.ProcessReceipt = function(receipt)
	local player = Players:GetPlayerByUserId(receipt.PlayerId)
	if player then
		onProductPurchase(receipt, player)
	end
end

-- Example usage: When a player steps on a part, prompt the purchase
local part = script.Parent

part.Touched:Connect(function(other)
	local player = Players:GetPlayerFromCharacter(other.Parent)
	if player then
		promptPurchase(player)
	end
end)
-- Replace this with your Dev Product ID
local devProductId = 1682137093

-- Reference to the Players service
local Players = game:GetService("Players")
local MarketplaceService = game:GetService("MarketplaceService")
local Workspace = game:GetService("Workspace")

-- Define the destination part
local destinationPart = Workspace.SkipStageLocations:WaitForChild("Extreme")

-- Function to handle the purchase of the Dev Product
local function onProductPurchase(receipt, player)
	if receipt.ProductId == devProductId then
		local character = player.Character
		if character and destinationPart then
			local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
			if humanoidRootPart then
				humanoidRootPart.CFrame = destinationPart.CFrame
			end
		end
	end
end

-- Function to prompt the purchase
local function promptPurchase(player)
	MarketplaceService:PromptProductPurchase(player, devProductId)
end

-- Connect the onProductPurchase function to the ProcessReceipt callback
MarketplaceService.ProcessReceipt = function(receipt)
	local player = Players:GetPlayerByUserId(receipt.PlayerId)
	if player then
		onProductPurchase(receipt, player)
	end
end

-- Example usage: When a player steps on a part, prompt the purchase
local part = script.Parent

part.Touched:Connect(function(other)
	local player = Players:GetPlayerFromCharacter(other.Parent)
	if player then
		promptPurchase(player)
	end
end)

here is a video i recorded of the issue happening including confirming that the part does in fact not specify that it should teleport to the “Impossible” part, it should be teleported to the “Normal” part and then the second one should be teleported to the “Hard” part but they both teleport to the impossible part… im extremely confused right now

1 Like

Is local devProductId = 1682137093 the same in each script?

1 Like

yea in every script i put the same dev product id

Then all the scripts are being triggered.

1 Like

oh lol ima try and change the dev product id for them all, if it works your reply will be marked as solution

it wasnt the solution, its still teleporting to the wrong part and i added debugs and it says that script 1 prompts the purchase, then the other script detects the purchase even though it has a different dev product id and then teleports the player, if i delete that script that detects it, then it does another random script too, i just tested it in the normal game and it runs when the player joins and it considers joining the same as buying, im just gonna give up for now and save a copy of the version with the skip stage and maybe come back to it eventually and focus on something else like building stages

I got it to work for me using this with the script set to client in each part and creating a RemoteEvent in replicated storage.

-- Reference to the Players service
local Players = game:GetService("Players")
-- Reference to RemoteEvent Placed In ReplicatedStorage
local SkipStage = game:GetService("ReplicatedStorage"):WaitForChild("BuyEvents"):WaitForChild("SkipStage")

local part = script.Parent

part.Touched:Connect(function(other)
	local player = Players:GetPlayerFromCharacter(other.Parent)
	if player then
		--Replace With Stage You want To Skip Ex: SkipStage:FireServer("Stage2") etc...
		SkipStage:FireServer("Stage1")
	end
end)

Then creating a single server script to handle the teleporting, and purchasing of devproduct.

-- Declare Empty devProductId
local devProductId

-- Reference to the Players service
local Players = game:GetService("Players")
local MarketplaceService = game:GetService("MarketplaceService")
local Workspace = game:GetService("Workspace")

--RemoteEvents
local SkipStage = game:GetService("ReplicatedStorage"):WaitForChild("BuyEvents"):WaitForChild("SkipStage")

-- Define the destination part
local SkipStagePosition

-- Bool Checks
local purchasing = false
-- Function to handle the purchase of the Dev Product
local function onProductPurchase(receipt, player)
	if receipt.ProductId == devProductId then
		local character = player.Character
		if character and SkipStagePosition then
			local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
			if humanoidRootPart then
				humanoidRootPart.CFrame = SkipStagePosition.CFrame
					
				purchasing = false
			end
		end
	end
end

-- Function to prompt the purchase
local function promptPurchase(player)
	purchasing = true
	MarketplaceService:PromptProductPurchase(player, devProductId)
end

-- Connect the onProductPurchase function to the ProcessReceipt callback
MarketplaceService.ProcessReceipt = function(receipt)
	local player = Players:GetPlayerByUserId(receipt.PlayerId)
	
	if player then
		onProductPurchase(receipt, player)
	end
end

SkipStage.OnServerEvent:Connect(function(player, Stage)
	if player and purchasing == false then
		--Replace With Your DevProductIds
		if Stage == "Stage1" then
			devProductId = 0000000000 --Use different Id than stage2
			SkipStagePosition = Workspace:WaitForChild("SkipLocations"):WaitForChild("Normal")
			promptPurchase(player)
		end
		
		if Stage == "Stage2" then
			devProductId = 0000000000 --Use different Id than stage1
			SkipStagePosition = Workspace:WaitForChild("SkipLocations"):WaitForChild("Hard")
			promptPurchase(player)
		end
		
	end
end)
1 Like