so i did some steps a roblox website told me to do by creating in game purchases in the game settings under the monetization tab. now, all i want is a button that if u click it it buys it, in a part though not a gui. ive searched everywhere but only found gamepass gui buttons not actually in game purchase PARTS buttons
You would use ClickDetectors and the MouseClick
event to prompt the player to purchase the game pass.
and does the script go in the part? and how do i script it? sorry i cant rlly script
The ClickDetector goes inside the Part and the Script goes inside the Click Detector.
okay, is there anywhere i can find help with the script? i cant script but cant find anywhere that someone has a tutorial or has the script
i dont understand a thing… can u help me
I give you a sample.
local MarketplaceService = game:GetService("MarketplaceService")
ClickDetector.MouseClick:Connect(function(player)
-- Prompt the gamepass to the player now
end)
okay. so i guess the – line is where the purchase actually happens and where the ID goes?
Ez explained for u
local MSS= game:GetService("MarketplaceService")
ClickDetector.MouseClick:Connect(function(player)
MSS:PromptGamePassPurchase(player.UserId,gamepassidhere)
end)
also watch : MarketplaceService | Documentation - Roblox Creator Hub
thats the thing, 1: whats the user id thing? if multiple people buy it there wont be a certain user id right? 2: it isnt a gamepass, its a ingame purchase, like those things u can buy multiple times (donations, in-game money) and so on
You prompt the player, not its UserId. It should be:
local MSS= game:GetService("MarketplaceService")
ClickDetector.MouseClick:Connect(function(player)
MSS:PromptGamePassPurchase(player,gamepassidhere)
end)
local MSS= game:GetService("MarketplaceService")
ClickDetector.MouseClick:Connect(function(player)
MSS:PromptProductPurchase(player.UserId,idhere)
end)
for u explained again: it gets the player if it clicks on the clickdetector (if ur using one)
2nd, player.UserId is needed bc it needs an 64 int value.
U prompt player.UserId or Player depends sometimes “Player” doesnt work^^
wait, okay so whos player id goes there, and also, can the purchase id go in the gamepass id place(which isnt a gamepass)
nvm hard to explain to u , I just send u a whole place where it has all the parts scripted ^^ , I feel like u started scripting 3 days ago.
so whats the script?? do i just remove the playerid part
The proper code will be:
local MSS = game:GetService("MarketplaceService")
ClickDetector.MouseClick:Connect(function(player)
MSS:PromptProductPurchase(player,idhere)
end)
There you go I made u a place : test.rbxm (3.0 KB)
local MSS= game:GetService("MarketplaceService")
local CD= script.Parent.ClickDetector
local idhere = 1090632600
CD.MouseClick:Connect(function(player)
MSS:PromptProductPurchase(player,idhere)
end)