Rotate a part to the camera's orientation, smoothly and slowly

oh right, im stupid sometimes, that’s causing the error lol

My current code right now: and it doesnt work, it only does it once

task.wait(3)
local timeToTake = 1 -- the amount of time to take
local alpha = 0 -- what the alpha starts at
local startCFrame = workspace.RotCenter.CFrame
game.Workspace.CurrentCamera:GetPropertyChangedSignal("CFrame"):Connect(function()
	local camOrientation = game.Workspace.Camera.CFrame-game.Workspace.Camera.CFrame.Position;
	local goalCFrame = CFrame.new(game.Workspace.RotCenter.Position)*camOrientation

	while alpha < 1 do
		workspace.RotCenter.CFrame = startCFrame:Lerp(goalCFrame, alpha)
		-- increment alpha based on how long wait() takes so that it'll be 1
		alpha = alpha + (wait() / timeToTake)
	end
end)



could you (for convenience) just disable that script and use my script in a new script (so you don’t need to overwrite the script for both our scripts)

Put startCFrame in the connection

Did it, and it only does it once, and its glitchy.

Oops sorry, put all of timeToTake, alpha and startCFrame inside

Now its super glitchy. (twitches left and right while orientating to the goal)

Looked at it more and it, isnt really smooth, it like orientates to it while twitching left and right, then stops in the middle, and goes super fast to the goal right after. The loop works, but the actual lerp is messed up.

Then yea just use Tweens lol, Lerp isn’t as smooth and is way more complicated

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