I have been trying to make a dev product and when you click it it should teleport. Im using this for an obby skip stage. Please help iv'e been trying to do this for ages.
Script:
local devpro = 0000000 - Devproduct ID local part = script.Parent script.Parent.MouseClick:connect(function(player) game:GetService("MarketPlaceService")PromptProductPurchase(player, productid) local Marketplaceservice = game:GetService("MarketplaceService") Marketplaceservice.ProcessReceipt = function(receiptInfo) for i, player in pairs (game.Players:GetChildren()) do if player.userId == receiptInfo.PlayerId then if receiptInfo.ProductId == devpro then local torso = player.Character.Torso torso.CFrame = CFrame.new(part.position) end end end return Enum.ProductPurchaseDecision.PurchaseGranted end
I don't know if you occluded the dev ID on purpose, but make sure you put in the correct thing.
I fixed the following:
You used a single dash as a comment instead of 2 (-
instead of --
)
You spelt connect
wrong. It's supposed to be with an uppercase C.
You misspelled MarketplaceService
at the onclickevent.
You did not use a : before PromptProductPurchase after getting the marketplace service.
You never closed the MouseClick function.
Your way of getting the player is inefficient, use GetPlayerByUserId
Your receipt processing code had broken end
statements and the return was at the wrong location.
You defined the product ID as "devpro" at the top but later on you use productid, which is thus unset.
local productid = 0000000 -- Devproduct ID local part = script.Parent local mps = game:GetService("MarketplaceService") script.Parent.MouseClick:Connect(function(player) mps:PromptProductPurchase(player, productid) end) mps.ProcessReceipt = function(receiptInfo) local player = Players:GetPlayerByUserId(receiptInfo.PlayerId) if receiptInfo.ProductId == devpro then local torso = player.Character.Torso torso.CFrame = CFrame.new(part.position) return Enum.ProductPurchaseDecision.PurchaseGranted; end return Enum.ProductPurchaseDecision.NotProcessedYet end
Overall, your code was honestly pretty bad. You should probably enhance your basic knowledge before getting started with more complicated subjects like this.