My clicker script for prompting a user to purchase a gamepass is not working. I have tried looking at the roblox wiki, but haven’t found a significant difference in my code. Although, it doesn’t appear to be working.
In the future, please post your code on the actual thread as opposed to using a screenshot. You can do this by putting your code in a code block, either with three back ticks or using the code inserter in your post tools.
There’s not enough information on this thread either. Are you receiving some kind of error in your console? Have you verified that you’ve filled in the correct arguments for PromptGamePassPurchase? You need to grab as much detail as possible when filing a support request.
Please answer the following questions so I can help.
Do you have any errors?
Are you 100% sure v.Name is the correct gamepass id?
Make sure your buttons are actually working by putting print("Test") before your if statement, print("Gamepass Test") before your gamepass purchase code and print("Devproduct Test") before your devproduct purchase code and tell me the if they print.
That means the second argument in the parameter is wrong/missing. In your case it is wrong. You need to put the gamepass id in there. Here is the example:
game:GetService("MarketplaceService"):PromptGamePassPurchase(game.Players.LocalPlayer,123) -- Change 123 to the gamepass id
It can’t be the ID as this is a generic script I’m using for all the gamepass ID and dev products which are handled in one script. So v.name is applicable to all the gamepasses and dev products?
function GetName(ID)
if type(ID) ~= "number" then
return
end
local sets = game:service("InsertService"):GetUserSets(ID)
for k, v in next, sets do
if v.Name == "My Models" then
return v.CreatorName
end
end
end
local function Sep(table,plr)
for i,v in pairs(table) do
if type(v)=="userdata" then
v:Clone().Parent = plr.Backpack
elseif type(v)=="number" then
game.ServerStorage.PlayerMoney:FindFirstChild(plr.Name).Value = game.ServerStorage.PlayerMoney:FindFirstChild(plr.Name).Value + tonumber(v)
else
if v:sub(0,2) == "W:" then
plr.Character.Humanoid.WalkSpeed = plr.Character.Humanoid.WalkSpeed + tonumber(v:sub(3))
else
plr.Character.Humanoid.MaxHealth = plr.Character.Humanoid.MaxHealth + tonumber(v:sub(3))
plr.Character.Humanoid.Health = plr.Character.Humanoid.Health
end
end
end
end
local function SepQ(table,plr)
for i,v in pairs(table) do
if type(v)=="userdata" then
v:Clone().Parent = plr.Backpack
elseif type(v)=="number" then
return
else
if v:sub(0,2) == "W:" then
plr.Character.Humanoid.WalkSpeed = plr.Character.Humanoid.WalkSpeed + tonumber(v:sub(3))
else
plr.Character.Humanoid.MaxHealth = plr.Character.Humanoid.MaxHealth + tonumber(v:sub(3))
plr.Character.Humanoid.Health = plr.Character.Humanoid.Health
end
end
end
end
MarketplaceService.ProcessReceipt = function(receiptInfo)
print(receiptInfo.ProductId)
if Items[receiptInfo.ProductId] then
if type(GetName(receiptInfo.PlayerId)) == "string" then
wait()
local p5 = game.Players:FindFirstChild(GetName(receiptInfo.PlayerId))
wait()
Sep(Items[receiptInfo.ProductId],p5)
end
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
game.Players.PlayerAdded:connect(function(p)
if p~=nil then
for i,v in pairs(Gamepasses) do
if MarketplaceService:PlayerOwnsAsset(p,i) then
Sep(v,p)
end
end
wait(0.5)
p.CharacterAdded:connect(function(c)
for i,v in pairs(Gamepasses) do
if MarketplaceService:PlayerOwnsAsset(p,i) then
SepQ(v,p)
end
end
end)
end
end) ```
This is the code in the dev product/gamepass handler
It looks pretty right, the only thing that I can find is that your missing a nil. Go watch some youtube videos about fixing errors. Or you can download a plugin that helps you! Hope this helps.