✓ Accepted answer
Because you store a single vector3 position in 1 variable which your mouse will probably never hit again. You really don't even need to check the position. You can use a property of mouse called Target. It returns the name of the part your mouse is pointing at; well that's what it prints but it also holds the instance object of it allowing you to travel through its hierarchy. So you can create a method like so:
local mouse = game.Players.LocalPlayer:GetMouse()
local target = game.Workspace.Door
mouse.Move:connect(function()
if mouse.Target == "Door" then
target.Transparency = 1;
target.CanCollide = false;
end
end)
Just the word door may be vague. As long as you don't have doors that you don't want people going through then you should be fine. Otherwise you would want to change the name of the others or use a separate method of checking where the part is in hierarchy if you organize the doors better. ( :IsDescendantOf() ).