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

door only moves to the right no matter what cframe i use?

Asked by 3 years ago

im trying to make a door that slides into the floor and i am using this code

local TweenService = game:GetService("TweenService")

local Panel = workspace.UnlockedDoor.door
local PanelRoot = Panel.PrimaryPart

local PanelSlideInfo = TweenInfo.new()

local PanelSlideTween = TweenService:Create(PanelRoot, PanelSlideInfo, {
    CFrame = PanelRoot.CFrame * CFrame.new(PanelRoot.Size.Y + 0, 0, 0)
})
wait(3)
PanelSlideTween:Play()

when i run the script the door keeps going to the right, i want the door to move down, but no matter what XYZ i plug into the vector3 it just wont change. whats wrong?

0
Maybe try CFrame:lerp() instead? acediamondn123 147 — 3y
0
Did you already try swapping the x and the z greatneil80 2647 — 3y

1 answer

Log in to vote
0
Answered by
RAFA1608 543 Moderation Voter
3 years ago

Hello!

CFrames are relative to the rotation of the object. For example, if I were to rotate a object 90 degrees couterclockwise in the Z axis, and then tried moving it 5 studs to the right in the X axis, it would go up instead of right, because CFrames are relative, or something. I am bad at explaining stuff.

Anyways, you can only add CFrames with the symbol *, which, despite common sense, adds CFrames instead of multiplying them. To get around that, you need to have a negative number instead of a positive number, like this:

CFrame = PanelRoot.CFrame * CFrame.new(-PanelRoot.Size.Y, 0, 0) --negative

If you're confused, you can see a detailed article about CFrames here, or, alternatively, you can ask me questions that aren't located in the article.

I hope this helps! Please excuse my bad explanation.

0
putting the minus in front of the PanetRoot.Size.Y thing did successfully make it go left but i still cant figure out how to make it move down thekingorespawn 2 — 3y
Ad

Answer this question