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

Is there a way to keep the orientation of an part, when your moving it using CFrame.new?

Asked by 4 years ago

So I have a gate script, But when it moves, it sets the orientation slowly back to 0, when we need it at 0,90,0. Is there any possible way to achieve this? Here is the server script:

local TweenService = game:GetService("TweenService")
local door1 = script.Parent.Parent.Parent.Part1
local tweeningInformation = TweenInfo.new(
    2,   
    Enum.EasingStyle.Linear,
    Enum.EasingDirection.Out,
    0,
    false,
    0
)
local door1Open = {CFrame = CFrame.new(-161.498, 15.143, -125.72)}
local door1Close = {CFrame = CFrame.new(-161.498, 5.666, -125.72)}
local tween1open = TweenService:Create(door1,tweeningInformation,door1Open)
local tween1close = TweenService:Create(door1,tweeningInformation,door1Close)
 local open = false
script.Parent.ClickDetector.MouseClick:Connect(function()
    if not open then 
    open = true
    tween1open:Play()
    else
    tween1close:Play()
open = false
    end
end)

1 answer

Log in to vote
0
Answered by 4 years ago

If you are trying to get an orientation of 0,90,0 for the part, you would multiply the current CFrame of the part by CFrame.Angles. Here is how you get the CFrame that has an Orientation of 90 degrees:

local cframe = workspace.PARTNAME.CFrame * CFrame.Angles(0,90,0)

Also, replace the location of the part with the part you want.

0
you can use lookvector Nakama_G 6 — 4y
0
Ah, I see, Let me try it and get back to you! Mrmonkeyman120 65 — 4y
Ad

Answer this question