MarketPlaceService:UserOwnsGamePassAsync not working?

Hey

So I am trying to make it so if a user owns the game pass, the part will delete (sort of like a VIP door). I tried using :UserOwnsGamePassAsync but it doesn’t seem to work?

Does anyone know what I am doing wrong and how I can fix it? There is nothing in the output and I have tried a few different methods Note: This is in a LocalScript. Hope someone can help me :slight_smile:

local MarketPlaceService = game:GetService("MarketplaceService")
local PlayerBoughtThisGamePass = MarketPlaceService:UserOwnsGamePassAsync(game.Players.LocalPlayer.UserId, 6271453)

if PlayerBoughtThisGamePass then
  script.Parent:Destroy()
end
1 Like

I don’t think you should use local script for it, someone can just change it to “if not something then

That would remove the part for everyone tho. That’s why I did it as a LocalScript so it only happens for that user…

That’s true, well you can make if something touches part, then you can check if that player owns gamepass

I think UserOwnsGamePassAsync returns true or false, so I made it when its true, the door will open(or anything you want to)

local MarketPlaceService = game:GetService("MarketplaceService")
local PlayerBoughtThisGamePass = MarketPlaceService:UserOwnsGamePassAsync(game.Players.LocalPlayer.UserId, 6271453)

if PlayerBoughtThisGamePass == true then
  script.Parent:Destroy()
end

Your issue here is that you’re using a LocalScript. You’re saying that script.Parent is a door, meaning it has to be in workspace, meaning a localscript can’t run there. Your localscript isn’t running, you’ll need to move your script, and reference the door from StarterGui, StarterPack, or StarterPlayer.

1 Like

So then put the script in StarterPlayerScripts, and find the part in workspace