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)
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)