Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Hpw do i make a gamepass prompt when touched script?

when player touch part, prompt gamepass

i tried this but it does not work

local mps = game:GetService("MarketplaceService")
local plr = game.Players.LocalPlayer

script.Parent.Touched:Connect(function(h)
	local hum = h.Parent:FindFirstChild("Humanoid")
	if hum ~= nil then
		mps:PromptGamepassPurchase(plr, 8875349)
	end
end

1 comment

0

You're back ey?

2 answers

✓ Accepted answer

I don't know why you have this in a local script, but this works just fine from a normal script, just search for the players name when it is touched

local mps = game:GetService("MarketplaceService")

script.Parent.Touched:Connect(function(h)
    local hum = h.Parent:FindFirstChild("Humanoid")
    if hum ~= nil then
		local plr = game.Players:FindFirstChild(player.Name)
        mps:PromptGamepassPurchase(plr, 8875349)
    end
end

Make the "P" at "PromptGamePassPurchase" uppercase, yours is lowercase (yours it PromptGamepassPurchase), I also think you didn't close the "Connect" at line 4. There is "end" at the end, but no (

local mps = game:GetService("MarketplaceService")
local plr = game.Players.LocalPlayer
script.Parent.Touched:Connect(function(h)
    local hum = h.Parent:FindFirstChild("Humanoid")
    if hum ~= nil then
        mps:PromptGamePassPurchase(plr, 8875349)
    end
end)

Honestly I don't know if it will work since my Roblox studio broke, but try it.

This discussion is preserved as it was. New answers, comments, and votes are closed.