Answered by
5 years ago Edited 5 years ago
The problem is that the CFrame values have a rotational value imbedded into them, and when you create a CFrame this value is set to 0,0,0.
To change this value you can use CFrame.Angles()
.
This is an example that lets you understand the context and syntax:
1 | CFrame.new( 0 , 0 , 0 ) * CFrame.Angles( 0 , 90 , 0 ) |
However, if you test out the code you will see that the Y value won't be 90 degrees. This is because CFrames use radians instead of regular degrees.
2 Pi is equal to 360 degrees in radians.
This means that 1 pi is 180 degrees, pi/2 is 90 degrees and so on.
Roblox has a function that converts regular degrees into radians, as well as a function that does the reverse.
math.rad()
expects a value (in degrees) and converts it into radians, neat!
Here is your script with this implementation:
01 | local model = script.Parent.Parent |
02 | local door = model.Door |
03 | local TweenService = game:GetService( "TweenService" ) |
04 | local scanner = script.Parent |
05 | local info = TweenInfo.new( |
07 | Enum.EasingStyle.Exponential, |
08 | Enum.EasingDirection.Out, |
18 | local drzwizam = { CFrame = CFrame.new( 33.95 , 3.49 , 24.98 ) * CFrame.Angles(math.rad( 0 ),math.rad( 0 ),math.rad( 0 )) } |
19 | local drzwiodw = { CFrame = CFrame.new( 33.95 , 3.49 , 31.462 ) * CFrame.Angles(math.rad( 0 ),math.rad( 0 ),math.rad( 0 )) } |
20 | local tweenotw = TweenService:Create(door, info, drzwiodw) |
21 | local tweenzam = TweenService:Create(door, info, drzwizam) |
23 | scanner.Touched:Connect( function (card) |
24 | if card.Name = = "Handle" and card.Level.Value = = 1 then |
However, since I don't know the full context of this door you'll have to change some of the values yourself. Good luck!