How do I create a player only door (I want them to click it and it opens)

I believe the title says most of it.

I need to create a door that upon clicking it will open and you can go through it, but only people that I specify can get in it. Here is the script, but I need the extension so only specific people can open it.
image

I wish for the door to function like this; https://gyazo.com/f8767e48c9821594e0323c4073b3069c
but so that only people that I authorize can do so.

You can use Collision Filtering | Roblox Creator Documentation to make specific players not collide with specific parts.

local isOn = true

local listOfPlayersUserIdsWhoCanEnter = {
     [40098276] = true
}

function on()
     script.Parent.Transparency = 0
     script.Parent.CanCollide = true
     script.Parent.Texture.Transparency = 0
end

function off()
     script.Parent.Transparency = 1
     script.Parent.CanCollide = false
     script.Parent.Texture.Transparency = 1
end

function onClicked(plr)
     if not listOfPlayersUserIdsWhoCanEnter[plr.UserId] then return end

     if isOn then
           off()
     else
           on()
     end
     isOn = not isOn
end

script.Parent.ClickDetector.MouseClick:Connect(onClicked)
on()
1 Like

Thank you so much, just tested it and it works.

Don’t forget to mark it as an answer. Glad I could help!