for i = 1,9 do v.Door.CFrame = v.Door.CFrame * CFrame.Angles(0, math.rad(math.pi/.3), 0) wait() end
So this code rotates my door, however, it doesn't do it in the way I want. I want it to rotate like a normal door, from a certain point instead what this does is just rotate it in its current position, like the door is not swinging open from a 'hinge' if that describes it better. How would I do this?
Hello There!
In this case, I would use something called PrimaryPart, a property in models. It can act as a hinge in your case.
First, create a model with 2 parts, one part being the door and part being a hinge on the side of the door.
Second, select the model and click PrimaryPart then select the hinge part. This will set that part to your primary part.
Now this is where the scripting comes in!
As told on the wikipedia, SetPrimaryPartCFrame does the following,
Sets the CFrame of the PrimaryPart. All other parts in the model will also be moved and will maintain their orientation and offset respective to the PrimaryPart. This function will throw an error if no PrimaryPart exists for the Model.
We can easily use a loop and some easy CFrame to make this door look real, such as :
local door = workspace['YourDoorModel'] for i = 1, 40 do door:SetPrimaryPartCFrame(door.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(2.25), 0)) wait() end
In this case, the door's rotation will move 2.25 40 times, which equals 90.
I hope this helped, :D