Rotating a part around pivot points question

Hi,

I am currently making a door that is opening using math.rad + tween service. The door rotates from the middle (normal pivot position of a part). However I want it to rotate from the side of the part like a door would. This is my code, I havent included any attempts to change the pivot point. I’ve tried changing pivot origin with scripts, doesnt do anything.

local part = game.Workspace.Door.Door1
local tweenservice = game:GetService(“TweenService”)
task.wait(5)
local tweeninfo = TweenInfo.new(8, Enum.EasingStyle.Bounce)
local Cframe = part.CFrame * CFrame.Angles(0, math.rad(90), 0)

local goal = {
CFrame = Cframe

}

local tween = tweenservice:Create(part, tweeninfo, goal)
tween:Play()

2 Likes

I think this should work, this is how I’ve done it in the past but there may be better ways of doing it.

local part = game.Workspace.Door.Door1
local tweenservice = game:GetService("TweenService")
local RunService = game:GetService("RunService")
local partPivot = part:GetPivot()
local partCFV = Instance.new("CFrameValue")
partCFV.Value = partPivot
task.wait(5)
local tweeninfo = TweenInfo.new(8, Enum.EasingStyle.Bounce)
local Cframe = partPivot * CFrame.Angles(0, math.rad(90), 0)

local goal = {
Value = Cframe

}

local tween = tweenservice:Create(partCFV, tweeninfo, goal)
tween:Play()

RunService.Stepped:Connect(function()
part:PivotTo(partCFV.Value)
end)
2 Likes

Still doesnt rotate from the end of the part like a door does

2 Likes

is the pivot position set to the end of the door?

2 Likes

All good it works now!! Thank you :slight_smile:

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.