Hello everyone,
So I have this script for a GUI with a button. When clicked it does the following:
local ID = 4715972 --ID
script.Parent.MouseButton1Click:Connect(function(p)
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(p.userId, ID) then
print("I'm working :D")
else
game:GetService("MarketplaceService"):PromptGamePassPurchase(p,ID)
end
end)
But then it gives this error: attempt to index local 'p' (a nil value).
It works with a normal button with a clickdetector but not for a GUI with a button. Why so and how do I fix this?
Game-pass (if neccessary idk): https://www.roblox.com/game-pass/4715972/
Thanks in advance! ~snewo12

2 comments
If this is a local script, use "local p = game.Players.LocalPlayer"
I get the following error: "players is not a valid member of DataModel"