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()
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)