Answered by
6 years ago Edited 6 years ago
You're probably missing "* CFrame.Angles()
" in your code, which is after both CFrames in both TweenInfos.
Try this
01 | local Gate = workspace:WaitForChild( "Gate" ) |
02 | local TweenService = game:GetService( "TweenService" ) |
03 | local Activated = false |
04 | local Tween 1 Information = TweenInfo.new( |
06 | Enum.EasingStyle.Linear, |
07 | Enum.EasingDirection.InOut |
09 | local Tween 2 Information = TweenInfo.new( |
11 | Enum.EasingStyle.Linear, |
12 | Enum.EasingDirection.InOut |
15 | CFrame = CFrame.new( 31.749 , - 26.276 , 16.473 )* CFrame.Angles(math.rad( 90 ), 0 , 0 ) |
18 | CFrame = CFrame.new( 31.749 , 25.761 , - 6.788 )* CFrame.Angles(math.rad( 0 ), 0 , 0 ) |
21 | local Open = TweenService:Create(Gate,Tween 1 Information,Tween 1 ) |
22 | local Close = TweenService:Create(Gate,Tween 1 Information,Tween 2 ) |
24 | script.Parent.MouseClick:Connect( function () |
25 | if Activated = = false then |
28 | elseif Activated = = true then |
Note 1: If you add CFrame.Angles()
without changing the X, Y, and Z values to radians (assuming you're using degress (like 90)), put math.rad(DEGREES)
first, and change DEGREES to your liking. math.Angles()
reads degress as radians (Without math.rad: 90 degrees = CFrame.Angles reads value as rads = 90 rads = 5156.62 degrees (I depend on Google Calculator)). More about Radians at https://en.wikipedia.org/wiki/Radian
Note 2: I used X in CFrame.Angles(X,Y,Z)
because I don't know how your gate is supposed to look like. I used a simple brick as a gate. If it is not the right rotation, transfer the math.rad(90)
to Y or Z and/or make the value negative to achieve the right rotation.
Hope this works for you.