I got this script that this site helped me make, but every time I make a new door, I have to tinkle and tweak the CFrame positions so it will open and close (and be in the correct place.) It becomes a hassle, and I dread the next time a level requires me to make a door
So, I want to make this door universal and be able to use in any position or place, but me being a noobie, I don't know where to start!
local Door = script.Parent
local distanceToOpen = 10
local used = false
function onClicked(playerWhoClicked)
local dist = playerWhoClicked:DistanceFromCharacter(Door.Position)
if dist <= distanceToOpen and not used then
used = true
Door.CFrame = CFrame.new(34.6, 12.3, 105.1)*CFrame.Angles(0,math.rad(-90),0)--opened
print("door opened")
wait(3)
used = false
Door.CFrame = CFrame.new(32.1, 12.3, 103.4)*CFrame.Angles(0,math.rad(0),0)--closed
print("door closed")
end
end
Door.ClickDetector.MouseClick:connect(onClicked)
(Script is inside an object (the door) and relies on a ClickDetector)

2 comments
I'm sorry, but I do not know where to go from here. Good idea with Vector, I knew I had to use math somehow (P.S. I didn't downvote you, and whoever did should contribute and answer this as well >:( )
Its fine, I probably deserved it, I'll explain it better with some code...