most likely because, you want to click it rather than use mouse.Button1 down event. As a result. It becomes harder to think like that
local player = game.Players.LocalPlayer;
local character = player.Character;
local mouse = player:GetMouse();
function onKeyPress(inputObject,gameProcessed)
if inputObject.UserInputType == Enum.UserInputType.MouseButton1 then
local doorToChar = mouse.Target:FindFirstChild("Door").CFrame = CFrame.new(mouse.Target:FindFirstChild("Door").x-10,mouse.Target:FindFirstChild("Door").y,mouse.Target:FindFirstChild("Door").z)
if(mouse.Target ~=nil and mouse.Target:FindFirstChild("Door") and character.Humanoid.Torso.Postion = = doorToChar) then
mouse.Target.Transparency = 1;
mouse.Target.CanCollide = false;
end
end
end -end of function
game:GetService("UserInputService").InputChanged:connect(onKeyPress)
I did not test it in studios. Yet this should work, if the case is your Door is called Door.