Hello all, I have a viewmodel in my game, and I don't just want it to just snap to the camera's position, but rather move to it. So I tried to use :lerp() but it doesn't really look too good. Here's the code;

local plr = game.Players.LocalPlayer;
local viewmodel = game.ReplicatedStorage:WaitForChild("viewmodel"):Clone()
viewmodel.Parent = workspace.CurrentCamera
local runService = game:GetService("RunService");

while true do	
	for i = 0, 1, 0.01 do 
		viewmodel.Head.CFrame = viewmodel.Head.CFrame:lerp(workspace.CurrentCamera.CFrame * CFrame.new(-0.25, -0.25, 0), i)
		runService.RenderStepped:Wait()
	end
end

Any and all help is appreciated!

2 comments

0

Why not update the CFrame every RenderStepped instead of while true do?

0

instead of having a while true do that just keeps on reseting the for loop giving it the illusion of being choppy, tie the for loop to an event.