Answered by
2 years ago Edited 2 years ago
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:
1 | script.Parent.Touched:Connect( function () |
2 | game.Workspace.MainDoor:MoveTo(Vector 3. new( 73.366 , 3.843 , - 7.959 )) |
3 | game.Workspace.MainDoor:PivotTo(game.Workspace.MainDoor:GetPivot() * CFrame.Angles(math.rad( 90 , 0 , 0 ), 0 , 0 )) |
4 | script.Parent:Destroy() |
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