Help Needed for a Gamepass Prompt Script

Hello!

I am in no means a scripter, and yet I am in need of a script. I have looked around online on several sites and videos but I simply can’t rack my mind around it, so I wanted to ask for help.

For a game I am currently assisting, I need a script whereby a gamepass purchase will be prompted when someone touches a part, and if they already own the gamepass, the prompt doesn’t appear. It seems rather simple when you put it out like that but I’m a tad stuck since I am not a scripter. Any help would be greatly appreciated!

All you have to do is watch a video on how to prompt a gamepass

than put this in the part that should be touched
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild(“Humanoid”) then
local playername = hit.Parent.Name
local PlayerToPromptPurchaseTo = game.Players:FindFirstChild(playername)

– code here to prompt the gamepass purchase but use the PlayerToPromptPurchaseTo as the player to prompt the gamepass to
end

if you need more help i would be happy to help more even make you a script!

You can use the MarketplaceService to prompt purchases to players and use the Touched event to detect when players touch the part and prompt the purchase. An example of how to put it all together can be seen below:

---> services
local MarketplaceService = game:GetService("MarketplaceService")

---> variables
local part = script.Parent -- might need to change this to where your part is, else just put this script inside the part and it'll work
local gamepassId = 1234567 -- put your gamepass id here

---> main
part.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChildOfClass("Humanoid") then
        local player = game.Players:GetPlayerFromCharacter(hit.Parent)
        if player then -- check that the player actually exists
            MarketplaceService:PromptGamePassPurchase(player,gamepassId)
        end
    end
end)

Some useful documentation for you:
MarketplaceService
MarketplaceService:PromptGamePassPurchase()
Touched
Players:GetPlayerFromCharacter()