I was following a tutorial regarding door rotation but also wanted to know how to make it rotate back into place once moved.
01 | local hinge = script.Parent:WaitForChild( "Hinge" ) |
02 | local door = script.Parent:WaitForChild( "Door" ) |
03 |
04 | local HINGEPOS = hinge.Position |
05 |
06 | for i = 1 , 15 do |
07 | wait() |
08 | door.CFrame = CFrame.new(HINGEPOS) * CFrame.Angles( 0 , math.rad(i* 6 ), 0 ) * CFrame.new( 0 , 0 , 2.25 ) |
09 | end |
10 | wait( 1 ) |
11 | for i = 1 , 15 do |
12 | wait() |
13 | door.CFrame = CFrame.new(HINGEPOS) * CFrame.Angles( 0 , math.rad(i*- 6 ), 0 ) * CFrame.new( 0 , 0 , 2.25 ) |
14 | end |
I couldn't find comments on the video asking nor any mention of it in the video itself.
do the same thing but make the angle negative
01 | local hinge = script.Parent:WaitForChild( "Hinge" ) |
02 | local door = script.Parent:WaitForChild( "Door" ) |
03 |
04 | local HINGEPOS = hinge.Position |
05 |
06 | for i = 1 , 15 do |
07 | wait() |
08 | door.CFrame = CFrame.new(HINGEPOS) --puts door at the hinge's position |
09 | * CFrame.Angles( 0 , -math.rad(i* 6 ), 0 ) --rotates door |
10 | * CFrame.new( 0 , 0 , 2.25 ) --shifts door forward |
11 | end |