local plr = game.Players.LocalPlayer
local ID = 0 -- Random ID I put
script.Parent.MouseDetector.MouseClick:Connect(function()
game.MarketPlaceService:PromptGamePassPurchase(plr, ID
end)
local plr = game.Players.LocalPlayer
local ID = 0 -- Random ID I put
script.Parent.MouseDetector.MouseClick:Connect(function()
game.MarketPlaceService:PromptGamePassPurchase(plr, ID)
end)
local ID = 0
script.Parent.MouseDetector.MouseClick:Connect(function(plr) --Adding plr after this specifies the player.
game:GetService("MarketPlaceService"):PromptGamePassPurchase(plr, ID) -- I added :GetService() to it, and you also forgot the ) at the end.
end)
My bad, I mis-capped marketplace service. try this:
local ID = 0
script.Parent.MouseDetector.MouseClick:Connect(function(plr) --Adding plr after this specifies the player.
game:GetService("MarketplaceService"):PromptGamePassPurchase(plr, ID) -- I added :GetService() to it, and you also forgot the ) at the end.
end)
local ID = 0
script.Parent.MouseDetector.MouseClick:Connect(function(plr) --Adding plr after this specifies the player.
game:GetService("MarketplaceService"):PromptGamePassPurchase(plr, ID) -- I added :GetService() to it, and you also forgot the ) at the end.
print("Purchase Prompted. ")
end)
local ID = 0
script.Parent.MouseDetector.MouseClick:Connect(function(plr) --Adding plr after this specifies the player.
game:GetService("MarketplaceService"):PromptProductPurchase(plr, ID) -- I added :GetService() to it, and you also forgot the ) at the end.
print("Purchase Prompted. ")
end)
This is if you want it to prompt a Dev Product and not a gamepass like you say.
It isn’t prompting purchase because you didn’t put any product id in the ID variable. You also forgot to put ) after game.MarketPlaceService:PromptGamePassPurchase(plr, ID. So it should be game.MarketPlaceService:PromptGamePassPurchase(plr, ID).
You were not charged because you were in Roblox Studio. Roblox does this so you are able to test purchases without getting charged. In Roblox game client it will actually charge you. So don’t worry about that.
It’s better practice to use game:GetService() instead of game..
Yes, use Script and not LocalScript.
So here is the improved and fixed script.
local MarketplaceService = game:GetService("MarketplaceService") -- Get MarketplaceService
local Id = 1121065450 -- Your dev product id
local ClickDetector = script.Parent.MouseDetector -- Your click detector
ClickDetector.MouseClick:Connect(function(player) -- On click, get player and do the following below
MarketplaceService:PromptProductPurchase(player, Id) -- Prompt the purchase, to the player with product id
end) -- End the function
Make sure that the Script is parented to the Part that contains MouseDetector object. Other than that happy scripting. If you have any questions, feel free to do so .