I’m trying to make a part smoothly move towards the players camera using the following code:
h.CFrame = h.CFrame:lerp((workspace.CurrentCamera.CFrame * CFrame.new(0.225,-0.2,-0.15)),0.25)
When the code executes, instead of smooth lerping the part hides somewhere
How do I fix that?
Thanks.
Quick edit: my whole code is this:
local h = game.ReplicatedStorage.Handle:Clone()
local camera = workspace.CurrentCamera
local head = game.Players.LocalPlayer.Character:WaitForChild("Head")
local function IsFirstPerson()
return (head.CFrame.p - camera.CFrame.p).Magnitude < 1
end
h.Parent = workspace.CurrentCamera
game:GetService("RunService").RenderStepped:Connect(function()
if IsFirstPerson() then
game:GetService("TweenService"):Create(h, TweenInfo.new(0.25,Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, 0, false, 0), {CFrame = workspace.CurrentCamera.CFrame * CFrame.new(0.225,-0.2,-0.15)}):Play()
end
end)