Hi there, I’m making a game and I have a proximityprompt here (inside of the player) that is supposed to prompt a product purchase but it isn’t, can I have some advice?
I’m using a LocalScript inside of the ProximityPrompt.
script.Parent.Triggered:Connect(function()
local plr = game.Players.LocalPlayer
game.MarketplaceService:PromptProductPurchase(plr, "1219020831")
end)
local MPService = game:GetService("MarketplaceService")
local gamepassid = 1219020831
script.Parent.Triggered:Connect(function(player)
MPService:PromptProductPurchase(player, "1219020831")
end)
The 2nd argument passed to “PromptProductPurchase” should be an integer value (not a string), also whenever a ProximityPrompt instance is triggered resulting in the “Triggered” event firing the player which caused the trigger is automatically passed as an argument to any function connected to the event, therefore all we need to do is declare a parameter in the function (which you can name anything) to handle the passed player instance, therefore defining the player isn’t necessary using “game.Players.LocalPlayer” isn’t needed.
local ID = 1219020831
script.Parent.Triggered:Connect(function()
local plr = game.Players.LocalPlayer
game.MarketplaceService:PromptProductPurchase(plr, ID)
end)
local player = game.Players.Localplayer
local productId = 1219020831
script.Parent.Triggered:Connect(function()
game.MarketplaceService:PromptProductPurchase(player, productId)
end)
Try the script above and see if it works. The product Id is the ID of your Developer Product.
Remember that the Localplayer has to be defined outside the function, not inside it.