Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Hpw do i make a gamepass prompt when touched script?

Asked by 4 years ago

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
0
You're back ey? kingblaze_1000 359 — 4y

2 answers

Log in to vote
1
Answered by 4 years ago

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
Ad
Log in to vote
0
Answered by 4 years ago

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.

Answer this question