Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Whats Wrong With My Developer Product Teleport Script?

Asked by
Rynappel 212 Moderation Voter
4 years ago

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

Log in to vote
0
Answered by
KDarren12 705 Donator Moderation Voter
4 years ago

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.

0
By the way, what I meant by "changing it" was about changing the script to a local script, not changing the script itself. KDarren12 705 — 4y
0
oh Rynappel 212 — 4y
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 Rynappel 212 — 4y
0
hmmm KDarren12 705 — 4y
View all comments (2 more)
0
It worked? KDarren12 705 — 4y
0
nope Rynappel 212 — 4y
Ad

Answer this question