How do i make a gamepass whitelist

I’m making a paid script

but I don’t want leaked versions to work

so I want it to check for a game pass
if the player owns the game pass the script will continue
if they don’t own the game pass they will be kicked
here is the code I have for the loader

local OPScriptLoader = {}
function OPScriptLoader:OMNI(plr)
	local Players = game:GetService('Players')
	local LoadScript = script:FindFirstChildOfClass('Script')
	LoadScript:Clone().Parent = Players[plr].PlayerGui
end
return OPScriptLoader

The obvious way would be to check if they actually own the game pass.
https://developer.roblox.com/en-us/api-reference/function/MarketplaceService/UserOwnsGamePassAsync

could you make it work for my script tho

You can do that yourself.
MarketplaceService — UserOwnsGamePassAsync

local Ok, Result = pcall(function()
   return MarketplaceService:UserOwnsGamePassAsync(userid, gamepass_id)
end)

if (Ok and Result) -- // If the call was successful and they own the gamepass.
then
   -- // Your code.
end

how do i make it kick them if they dont own it

if (Ok)
then
	if (Result)
	then
		-- // They own the gamepass.
	else
		-- // They don't own the gamepass: kick them.
		PlayerInstance:Kick()
	end
end

im confused could you add that to the code above

You should be able to do this yourself, but here:

local Ok, Result = pcall(function()
	return MarketplaceService:UserOwnsGamePassAsync(userid, gamepass_id)
end)

if (Ok) -- // If the call was successful.
then
	if (Result) -- // Returns true if they own the gamepass, false otherwise.
	then
		-- // They own the gamepass.
	else
		-- // They do not own the gamepass: kick them.
		PlayerInstance:Kick()
	end
end

could you make a version with the gamepass only and not userid

MarketplaceService:UserOwnsGamePassAsync has two parameters, you can’t do that.
https://gyazo.com/7f5c326427a1e0efaa1fd3a6f16aac7a

But, you could make your own module which only has the player / userid as a parameter, then the module will then deal with the gamepass id.

how could i find the player’s user id
if the module script is loaded with a require function

You’ll need to check if they own the gamepass before using its functions then.
They will still be able to load it, but not use it unless they actually own the gamepass.

Also, you are using FindFirstChildOfClass incorrectly.
You don’t even need to use that function, use the dot operator instead and make sure the script’s name is Script.
https://developer.roblox.com/en-us/api-reference/function/Instance/FindFirstChildOfClass

hey i can’t find a way to get user id to work


here is what it looks like inputting your code in op script
its the script that is loaded with the code before

userid would be Player.UserId.