The code itself works. When the code is executed, and a player or part is in the way it will move the part up.
--[[ position and rotation when door is open
R = -180, -0, -90
P = -6.505, 8, 19.495
]]--
--[[position and rotation when door is closed
R = 90, 90, 0
P = -4.6, 8, 17.5
--]]
function openDoor()
if workspace.Door.DoorOpenBool.Value == false then
--open the door
script.Parent.DoorOpen.Rotation = Vector3.new(-180, -0, -90)
script.Parent.DoorOpen.Position = Vector3.new(-6.505, 8, 19.495)
workspace.Door.DoorOpenBool.Value = true
else if workspace.Door.DoorOpenBool.Value == true then
--close the door
script.Parent.DoorOpen.Rotation = Vector3.new(90, 90, 0)
script.Parent.DoorOpen.Position = Vector3.new(-4.6, 8, 17.5)
workspace.Door.DoorOpenBool.Value = false
end
end
end
script.Parent.ClickDetector.MouseClick:connect(openDoor)
When you open the door and a part is where the door's position should change to, it will place it in a location where no parts block it. Is there any way to make it so that the position change is correct regardless of a part or player in that location? If not is there a way to make it ignore the code if there is an object in that location? If not that is there any workaround for this?
Thanks, and I hope this made since.
