I made a script where my door is supposed to change position and rotation when it is clicked. It's not working and I don't know why. I kept looking for little details but nothing works. Here is my attempt at the script.
part = script.Parent
position = Vector3.new(0.65, 3.675, -26.85)
rotation = Vector3.new(0, 60, 0)
mainposition = Vector3.new(-0.45, 3.675, -28.45)
mainrotation = Vector3.new(0, 0, 0)
script.Parent.ClickDetector.MouseClick:connect(function(playerWhoClicked)
if (part.Position == position and part.Orientation == rotation) then
part.Position = part.Position.mainposition
part.Orientation = part.Orientation.mainrotation
part.CanCollide = true
elseif (part.Position == mainposition and part.Orientation == mainrotation) then
part.Position = part.Position.position
part.Orientation = part.Orientation.rotation
part.CanCollide = false
else
print("Door script failed.")
end
end)

5 comments
In the first If statement you say part.Position.mainposition when it seems like you were trying to access the variable "mainposition" you created at the beginning. Same with the mainrotation, position and rotation later in the script. Maybe try this: if (part.Position == position and part.Orientation == rotation) then part.Position = mainposition part.Orientation = mainrotation part.CanCo
that's the exact thing I did
well, before, I changed it because it wasn't working either.
BTW why are you using a vector 3 for rotation? that will just move the part, not rotate it. Look into Cframe.Angles
ohh ok thanks