Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Why does my door change orientation while opening?

Asked by 5 years ago

So I made a tween service door but for some reason it changes its orientation while opening and it starts opening the wrong way.

01local model = script.Parent.Parent
02local door = model.Door
03local TweenService = game:GetService("TweenService")
04local scanner = script.Parent
05local info = TweenInfo.new(
06    2,
07    Enum.EasingStyle.Exponential,
08Enum.EasingDirection.Out,
090,
10false,
110
12 
13 
14 
15 
View all 34 lines...

If you have any idea of why this is happening then please respond.

0
Did you anchored the door ? Nguyenlegiahung 1091 — 5y

2 answers

Log in to vote
0
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:

1CFrame.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!

1math.rad(180) -- outputs pi's value

Here is your script with this implementation:

01local model = script.Parent.Parent
02local door = model.Door
03local TweenService = game:GetService("TweenService")
04local scanner = script.Parent
05local info = TweenInfo.new(
06       2,
07       Enum.EasingStyle.Exponential,
08       Enum.EasingDirection.Out,
09       5,
10       false,
11        0
12 
13 
14 
15 
View all 34 lines...

However, since I don't know the full context of this door you'll have to change some of the values yourself. Good luck!

Ad
Log in to vote
0
Answered by
JesseSong 3916 Moderation Voter Community Moderator
5 years ago

TweenService:https://developer.roblox.com/en-us/api-reference/function/TweenService/Create

Nothing seems wrong with you script but I edited some parts:

01local model = script.Parent.Parent
02local door = model.Door
03local TweenService = game:GetService("TweenService")
04local scanner = script.Parent
05local info = TweenInfo.new(
06       2,
07       Enum.EasingStyle.Exponential,
08       Enum.EasingDirection.Out,
09       5,
10       false,
11        0
12 
13 
14 
15 
View all 34 lines...

Answer this question