Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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?

2 comments

0

Maybe try CFrame:lerp() instead?

0

Did you already try swapping the x and the z

1 answer

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.

1 comment

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

This discussion is preserved as it was. New answers, comments, and votes are closed.