I think the easiest way to fix this is to change the 180 to 179 since it will tween to the closest direction so basically make it so its 1 degree closer to where it is supposed to be when closed
Lerping fixed some of it, which is good.
However when the starting rotation value is 180, the lerp goes crazy trying to add 89 to 180 since orientation can’t go over 180.
i used a fixed value for the orientation, used tweening btw, Read The Ending Parts, was way too simple? ;-;
local ts = game:GetService("TweenService")
local rs = game:GetService("RunService")
local door = script.Parent.door
local pivot = script.Parent.pivot
local doorRot = door.Orientation.Y
local open = script.Parent.open
local flipped = false
local openSound = door.opensfx
local closeSound = door.closesfx
local ti = TweenInfo.new(
0.5 -- Time
)
door.ProximityPrompt.Triggered:Connect(function(player)
local char = player.Character
local doortochar = (char.HumanoidRootPart.Position - door.Position).Unit
local doorangle = door.CFrame.LookVector
local dot = doortochar:Dot(doorangle)
if open.Value then
open.Value = false
flipped = false
closeSound:Play()
else
open.Value = true
if dot > 0 then
flipped = false
else
flipped = true
end
openSound:Play()
end
end)
local offset = pivot.CFrame:inverse() * door.CFrame -- offset before rotation
rs.Heartbeat:connect(function(dt)
if open.Value then
if flipped then
ts:Create(pivot , ti , {Orientation = Vector3.new(0 , 90 , 0)}):Play()
else
ts:Create(pivot , ti , {Orientation = Vector3.new(0 , -90 , 0)}):Play()
end
else
ts:Create(pivot , ti , {Orientation = Vector3.new(0 , 0 , 0)}):Play()
end
door.CFrame = pivot.CFrame * offset -- apply offset to rotated hinge
print(flipped)
end)
well idk about that, it’s really weird… my best idea is to use CFrame or an if statement so it never reaches 180 or another solution is using “hings” its an item in roblox but it isnt very practical, I need to go now, if it isn’t solved when I comeback I’ll look more through it! Have a nice day!