Gamepass Service | Scripting Help needed

  1. What do you want to achieve?
    I want to make a script that checks if the game owner has purchased the product and it is not shared with anyone else. If the game owner doesn’t have the product purchased it gets deleted in the workspace/server script service.

  2. What is the issue?
    I can’t find any way how to make it.

  3. What solutions have you tried so far?
    I have tried to search it on the developer hub and the whole internet but didn’t find.

If you could provide me with any information or help me to find the solution I would appreciate it, many thanks!

I would use MarketplaceServer:UserOwnsGamePassAsync which returns a bool. Then you would check if the function returned true (owns) or false (does not own), and if it is false then you would proceed to delete your product from their game.

But how would I mention the game owner?

I would pass game.CreatorId as the first parameter to reference the game owner.

Would this work?

local MarketPlace = game:GetService("MarketplaceService")

local gameowner = game.CreatorId

if MarketPlace:UserOwnsGamePassAsync(gameowner,10163160) then
	else game.Workspace.Model1:Destroy()
end

You could just use the not operator and remove the else.

local MarketPlace = game:GetService("MarketplaceService")

local gameowner = game.CreatorId

if not MarketPlace:UserOwnsGamePassAsync(gameowner,10163160) then
   game.Workspace.Model1:Destroy()
end

The not operator inverts the condition. So that means true is false and false is true. Sorry if I am confusing you, but either way works.

1 Like

Alrighty, thank you for help! Much appreciated! :slight_smile:

2 Likes