Obby pads not working

I ran into an issue, my prompt purchase script for my friend’s obby game isn’t working. ( this is one of those kind of pads you’d touch )
Code

local MarketplaceService = game:GetService("MarketplaceService")
function onTouched(hit)
	local plr0  = hit.Parent.Name
local plr = plr0
local h = hit.Parent:findFirstChild("Humanoid")
if h ~= nil then

MarketplaceService:PromptGamePassPurchase(plr,6108469)



end
end
script.Parent.Touched:connect(onTouched)

Thanks

1 Like

You’re getting the string of the players name. You’ll need to do hit.Parent instead.
plr needs to be the player.

Is this code in a serverscript? ignore this: ok this is long enough

Your plr variable is a string. You should use Players:GetPlayerFromCharacter() in order to get the player.

local MarketplaceService = game:GetService("MarketplaceService")
local function onTouched(hit)
    local m = hit:FindFirstAncestorOfClass("Model")
    if m and m:FindFirstChildOfClass("Humanoid") then
        local plr = game.Players:GetPlayerFromCharacter(m)
        MarketplaceService:PromptGamePassPurchase(plr,6108469)
    end
end
script.Parent.Touched:connect(onTouched)
1 Like

Thank you, just realized that was a stupid mistake…