I made this part where it has rotation limits on Y orientation. It can be faced at the front and back and made it update in a loop using RunService. This lerp use a tween value then I made a variable alpha and left it there in a loop due to not knowing how to implementing it to my code. Here’s the code along with the footage of how this works below.
local Runservice = game:GetService("RunService")
local TweenService = game:GetService("TweenService")
local Part = script.Parent
local repPart = workspace.Part
local Target = workspace.Target
Runservice.Stepped:Connect(function()
local alpha = TweenService:GetValue(0.18, Enum.EasingStyle.Sine , Enum.EasingDirection.InOut)
local unitz = ((Part.Position - Target.Position).Unit).Z -- Determine where where the part is facing
-- Facing to the front
if unitz == math.clamp(unitz,-1,-0.1) then
Part.CFrame = CFrame.lookAt(Part.Position,Target.Position)
Part.Orientation = Vector3.new(0,math.clamp(Part.Orientation.Y%360,135,225),0)
end
-- Facing to the back
if unitz == math.clamp(unitz,0.1,1) then
Part.CFrame = CFrame.lookAt(Part.Position,Target.Position)
Part.Orientation = Vector3.new(0,math.clamp(Part.Orientation.Y,-(45%360),45%360),0)
end
end)