How to make model move smoother

I have a script that lets me move a model with the use of key binds, however, they move pretty abruptly.
The model is a spotlight, which if you have been to concerts, or seen them up close, moves in a smoother manner, sort of like a slow gradual increase of speed in the beginning, and a gradual slow down when it stops. (not sure how to explain it but think of the beginning and end of a sine wave)

local userInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local SpotlightHead = game.Workspace.Spotlight.Arm.Head
local UpdateCon

userInputService.InputBegan:Connect(function(input, gameProcessedEvent)
	if input.UserInputType ~= Enum.UserInputType.Keyboard then return end
	if input.KeyCode ~= Enum.KeyCode.KeypadEight then return end

	if UpdateCon then
		UpdateCon:Disconnect()
		UpdateCon = nil
	end

	UpdateCon = RunService.Heartbeat:Connect(function(dt)
		local newCFrame = SpotlightHead.PrimaryPart.CFrame * CFrame.Angles(0.05, 0, 0)
		SpotlightHead:SetPrimaryPartCFrame(newCFrame)
	end)
end)

userInputService.InputEnded:Connect(function(input, gameProcessedEvent)
	if input.UserInputType ~= Enum.UserInputType.Keyboard then return end
	if input.KeyCode ~= Enum.KeyCode.KeypadEight then return end
	if not UpdateCon then return end

	UpdateCon:Disconnect()
	UpdateCon = nil
end)

This is the script for the forward motion. (StarterPlayerScripts)
If you know a way to make this smoother, let me know!

Could you send a model (or just a placeholder with all the correctly named parts) with the script included? It’s hard to test out animations without being able to actively see what’s happening.

Here’s the model and all the movement scripts. (Place the folder in StarterPlayerScripts)

My bad, wrong link.

You could lerp or tween the cframe, if you don’t like the feel of that you could always use something like hinge constraints to get a more smooth physics based feel

1 Like

How would I replace the CFrame angles (or another value) with a tween?

Create a CFrame value and update the actual cframe with the CFrameValue.Value

for the instance for the tween put in the actual primary part and just adjust its cframe