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

Whats Wrong With My Developer Product Teleport Script?

So I have a script where you click a part and it prompts the purchase of a Developer Product. Here is the script:

script.Parent.MouseClick:Connect(function(player)
	local ID = 618642828
	game:GetService("MarketplaceService"):PromptProductPurchase(player, ID)
end)

But that's not what I need help with. I have this script which is supposed to teleport you when you purchase the Developer Product. It doesnt teleport me though. Can anybody tell me what ive done wrong? Please help or at least tell me what to do! Thanks! (script)

local MarketplaceService = game:GetService("MarketplaceService")
local devproductid = 618642828

MarketplaceService.ProcessReceipt = function(receiptInfo)
    for i, player in pairs(game.Players:GetChildren()) do
        if player.userId ==receiptInfo.PlayerId then
            if receiptInfo.ProductId == devproductid then
                game.Players.LocalPlayer.Character.Humanoid.Torso = CFrame.new(-244, 5, 185)
            end
        end
    end
    return Enum.ProductPurchaseDecision.PurchaseGranted
end

btw when I check the output it says: -Workspace.Part.Script:8: attempt to index field 'LocalPlayer' (a nil value)

And also it a Script not LocalScript.

1 answer

✓ Accepted answer

The problem is: LocalPlayer cannot be run on a script, only a LocalScript... So maybe changing it would be a good idea? I'm not sure what else i could tell you.

6 comments

0

By the way, what I meant by "changing it" was about changing the script to a local script, not changing the script itself.

0

oh

0

Well i tried a local script and it didnt work. then i checked the output. Nothing. I added a print function to ALL the lines to see where the code stops. Still, nothing. Help

0

hmmm

0

It worked?

0

nope

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