I've figured out how to change the position of a model using MoveTo, but I am not sure what piece of script will allow me to also change the orientation of the model. (I have already set the primary part for the model which is called 'MainDoor')
script.Parent.Touched:Connect(function() game.Workspace.MainDoor:MoveTo(Vector3.new(73.366, 3.843, -7.959)) --line of code to change orientation of MainDoor script.Parent:Destroy() end)
You can rotate and move models using :PivotTo(). This is function that can be used to make a model to go a CFrame with a set angle. To make the model only rotate, this can be easily done. Try this piece off code:
script.Parent.Touched:Connect(function() game.Workspace.MainDoor:MoveTo(Vector3.new(73.366, 3.843, -7.959)) game.Workspace.MainDoor:PivotTo(game.Workspace.MainDoor:GetPivot() * CFrame.Angles(math.rad(90,0,0),0,0)) script.Parent:Destroy() end)
All that I have added is game.Workspace.MainDoor:PivotTo(game.Workspace.MainDoor:GetPivot() * CFrame.Angles(math.rad(90,0,0),0,0))
, so I will explain that now.
First, we get the model which is the MainDoor. We then call :PivotTo(). This will be used to change the pivot. In the brackets, we then get the model again and call :GetPivot() to get the model's current pivot. We then times that pivot by a angle cframe, 90, 0, 0. math.rad converts an angle in degrees to radians. This should then rotate the model.
Some useful links:
Edit: I have replaced game.Workspace.MainDoor:PivotTo(game.Workspace.MainDoor:PivotTo:GetPivot * CFrame.Angles(math.rad(90,0,0),0,0))
, with game.Workspace.MainDoor:PivotTo(game.Workspace.MainDoor:GetPivot() * CFrame.Angles(math.rad(90,0,0),0,0))
, so I will explain that now. to fix a error