When I test my button, if it sees I own a certain asset it is supposed to teleport me somewhere. And even though I already own the gamepass specified in the script, it still prompts the purchase and doesn't teleport.
local gamepassID = 2657409
local assetID = 870836117
local debounce = false
local function OwnsShades(Hit)
if debounce == false then
debounce = true
local plr = game.Players:GetPlayerFromCharacter(Hit.Parent)
if plr then
if game:GetService("MarketplaceService"):PlayerOwnsAsset(plr,assetID) then
print(plr.Name .. " owns the Midnight Shades")
plr.MoveTo(workspace.Grass.Position)
else
print(plr.Name .. " doesn't own the shades")
game:GetService("MarketplaceService"):PromptGamePassPurchase(plr, gamepassID)
end
wait(1)
debounce = false
end
end
end
script.Parent.Touched:Connect(OwnsShades)

2 comments
For test purposes I think if you do it in studio, it will do a purchasing test as if you were testing in game transitions.
It doesn't work when i publish it either.