Tweening Orientation

Context: I’ve been trying to create a script where a part’s orientation changes when a ProximityPrompt is activated. To do this I have jumbled up a few of my existing scripts to do this, as usual, it didn’t work. So, if anyone could help me yto fix this, I would really appreciate it!

local Door = script.Parent.Parent

local TweenService = game:GetService("TweenService")

script.Parent.Triggered:Connect(function()

local DoorTween = TweenService:Create(Door, TweenInfo.new(1), {Position = Door.Orientation * CFrame.Angles(0,math.rad(90),0)})

DoorTween:Play()

end)

Thanks. :slightly_smiling_face:

3 Likes

You can tween orientation by using CFrame instead.

local Door = script.Parent.Parent

local TweenService = game:GetService("TweenService")

script.Parent.Triggered:Connect(function()

local DoorTween = TweenService:Create(Door, TweenInfo.new(1), {CFrame = Door.CFrame * CFrame.Angles(0,math.rad(90),0)})

DoorTween:Play()

end)
5 Likes

I haven’t tested this but it should work:

local TweenService = game:GetService("TweenService")

local prompt = script.Parent
local door = prompt.Parent


prompt.Triggered:Connect(function()
    TweenService:Create(
        door,
        TweenInfo.new(1),
        {Orientation = Door.Orientation + Vector3.new(0, 90, 0)}
    ):Play()
end)
2 Likes