Teleport to location developer product

Im trying to make a script that makes you be able to “teleport to top” in a obby type game. To cheat your way up using robux.
The mouse doesnt change into a finger when hovering over the part and clicking it does nothing.
Locations:
image

local part = script.Parent
local productId = 1365882498 
local teleportLocation = Vector3.new(55, 52.85, -24) 

part.ClickDetector.MouseClick:Connect(function(player)
	local success, message = game:GetService("MarketplaceService"):PromptProductPurchase(player, productId)
	if success then
		local character = player.Character
		character:MoveTo(teleportLocation)
	else
		print(message)
	end
end)

instead of teleporting the whole character, try using the the humanoid root part that controls it position. This script should work:

local part = script.Parent
local productId = 1365882498 
local teleportLocation = Vector3.new(55, 52.85, -24) 

part.ClickDetector.MouseClick:Connect(function(player)
	local success, message = game:GetService("MarketplaceService"):PromptProductPurchase(player, productId)
	if success then
		local character = player.Character.HumanoidRootPart
		character:MoveTo(teleportLocation)
	else
		print(message)
	end
end)

i forgot to mention, the developer product purchase screen also doesnt show up.

I just wanted to quickly say that the mouse not changing into a finger is a bug going around with ClickDetectors right now.
Clickdetectors by default should change the cursor int oa finger, even without scripts.

1 Like

I could be mistaken but when you use a success/error function, shouldn’t it be in a pcall?

1 Like

like this?

local part = script.Parent
local productId = 1365882498 
local teleportLocation = Vector3.new(55, 52.85, -24) 

part.ClickDetector.MouseClick:Connect(function(player)
    local success, message = pcall(function()
        game:GetService("MarketplaceService"):PromptProductPurchase(player, productId)
    end)
    if success then
        local character = player.Character
        character:MoveTo(teleportLocation)
    else
        print(message)
    end
end)

Yes, like that. A pcall function will return a success or fail, which would trigger your if statement.

I have no clue what everyone else here is talking about lol. You can’t pcall :PromptProductPurchase because it doesn’t return anything. It’s just used to prompt the purchase, you need to actually have logic on the server to handle purchase requests.

Also, local scripts inside workspace do not run.

I’ll give you a step by step guide to fix your problem.

  1. Replace your LocalScript with a normal script and paste this inside:
--//Services
local MarketplaceService = game:GetService("MarketplaceService")

--//Variables
local Part = script.Parent

--//Controls
local ProductId = 1365882498 

--//Functions
Part.ClickDetector.MouseClick:Connect(function(player)
	MarketplaceService:PromptProductPurchase(player, ProductId)
end)
  1. Add a new script in ServerScriptService and paste this inside:
    image
--//Services
local Players = game:GetService("Players")
local MarketplaceService = game:GetService("MarketplaceService")

--//Tables
local productFunctions = {
	[1365882498] = function(player)
		local character = player.Character
		
		if character then
			character:PivotTo(CFrame.new(Vector3.new(55, 52.85, -24)))
		end
	end,
}

--//Functions
MarketplaceService.ProcessReceipt = function(receiptInfo)
	local player = Players:GetPlayerByUserId(receiptInfo.PlayerId)

	if not player then
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end

	local Function = productFunctions[receiptInfo.ProductId]
	local success, result = pcall(Function, player)

	if not success or not result then
		warn("Error occurred while processing a product purchase")
		print("\nProductId:", receiptInfo.ProductId)
		print("\nPlayer:", player)

		return Enum.ProductPurchaseDecision.NotProcessedYet
	end

	return Enum.ProductPurchaseDecision.PurchaseGranted
end
  1. Everything should work now, if there are any errors please tell me them and I will fix it.
2 Likes

It works! Thank you, I put it as solution.

1 Like

No problem. If you have any more questions, feel free to ask.

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