Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why does this teleport prior to the purchase?

In Central Alert I want you to have the user buy something that teleports you. It actually teleports you and never even mentions the purchase. Why doesn't this work? The first is the server script and the second is the client script.

local MarketplaceService = game:GetService("MarketplaceService")
local VIP = 19230420
local PurchaseHistory = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
 
MarketplaceService.ProcessReceipt = function(receiptInfo) 
    -- find the player based on the PlayerId in receiptInfo
    for i, player in ipairs(game.Players:GetChildren()) do
        if player.userId == receiptInfo.PlayerId then
            -- check which product was purchased (required, otherwise you'll award the wrong items if you're using more than one developer product)
            if receiptInfo.ProductId == VIP then
                game.Workspace.Player.Torso.CFrame = CFrame.new(Vector3.new(10, 325.100006, 61, 1, 0, 0, 0, 1, 0, 0, 0, 1))
else
            end
        end	
    end
    -- record the transaction in a Data Store
    local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_purchase_" .. receiptInfo.PurchaseId
    PurchaseHistory:IncrementAsync(playerProductKey, 1)	
    -- tell ROBLOX that we have successfully handled the transaction (required)
    return Enum.ProductPurchaseDecision.PurchaseGranted		
end
local MarketplaceService = Game:GetService("MarketplaceService")
local buyButton = StarterGui.buyButton
local productId = 19230420
 
StarterGui.buyButton.MouseButton1Click:connect(function()
	MarketplaceService:PromptProductPurchase(player, productId)
end)

EDIT: The server script is StarterGui.buyButton.Script The client script is StarterPack.Script

1 answer

Are you trying to make it show the purchase??

3 comments

0

Yes.

0

Why, to show the person that there purchase was successful??

0

Never mind. I ONLY want you to be teleported if you purchase the item. So no.

This discussion is preserved as it was. New answers, comments, and votes are closed.