Ok so, I have an issue. I made it to where when you touch the part the gamepass prompts you with a purchase ui. When the person buys the gamepass whenever they walk through the gamepass door its shows the the “You already own this item” message and it is really annoying. How do I stop this from happening.
here is the script
–Made by HB0MAX
local Players = game:GetService(“Players”)
local MarketplaceService = game:GetService(“MarketplaceService”)
local function onTouch(hit)
local player = Players:GetPlayerFromCharacter(hit.Parent)
if player then
MarketplaceService:PromptGamePassPurchase(player, YOUR ID HERE) – gamepass ID
end
end
I’d imagine that if you owned the Gamepass, you can’t really prevent that from happening…
To stop the message from appearing though, you could use MarketPlaceService to detect whether or not the player owns that gamepass, then prompt the purchase accordingly.
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local PassId = -- your gamepass ID goes here
script.Parent.Touched:Connect(function(hit)
local player = Players:GetPlayerFromCharacter(hit.Parent)
if player then
if MarketplaceService:UserOwnsGamePassAsync(player.UserId, PassId) then
-- user already owns the gamepass, do nothing
else
-- user does not own the gamepass, rest of your code goes here
end
end
end)