So i have a script that makes the door cancollide false and the transparency to 1 if you have the gamepass but i wanna make it only open to me i tested it and the chasing npc i have could still go through it even tho it doesent have the gamepass. How can i make it only open to the player that has the gamepass and not the npcs that dont have it
local MarketplaceService = game:GetService("MarketplaceService") local Players = game:GetService("Players") local gamePassID = 6489429 --Replace this set of numbers with your gamepass id function onPlayerSpawned(player) local hasPass = false local success, message = pcall(function() hasPass = MarketplaceService:UserOwnsGamePassAsync(player.userId, gamePassID) end) -- The script below is for checking whether or not the player has the gamepass. if not success then warn("Error while checking if player has pass: " .. tostring(message)) return end if hasPass == true then game.Workspace.GamepassDoor.Gamepass.CanCollide = false game.Workspace.GamepassDoor.Gamepass.Transparency = 1 end end game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function() onPlayerSpawned(player) end) end) Players.PlayerAdded:Connect(onPlayerSpawned)