Touch part and check for gamepass not working

Hello, I’m trying to make a script that when you touch a part it checks if you have the gamepass and if you do have it execute code but it keeps printing that i don’t have the gamepass when I do own it, How do i fix this??

Thanks for the help!

local id = 2044283


local Players = game:GetService("Players")
 
local part = script.Parent
local function onTouched(part)
	local player = Players:GetPlayerFromCharacter(part.Parent)
	if not player then return end
	
 

    if game:GetService("GamePassService"):PlayerHasPass(player, id) then 
        print(player.Name .. "Gamepass Owned")
    else
        print(player.Name .. "No gamepass owned")
    end


end
part.Touched:Connect(onTouched)
2 Likes

PlayerHasPass is deprecated and is only in use for game passes that have a legacy id on the catalog id system. PlayerHasPass would check for /catalog/id instead. You should be using UserOwnsGamePassAsync for any work involving game passes as it respects the game pass id system.