Hey there, I’m currently having an issue with my lock-on script. It works fine; but the issue is that the camera spazzes out when I move in too close to the target.
This is my part of the code:
spawn(function()
while Focused do
local B = nearestPart.Position
local A = char.HumanoidRootPart.Position
local Offset = Vector3.new(5,1,0)
local V = B + ((A + Offset) - B).Unit * ((A - B).Magnitude + 8)
Cam.CFrame = CFrame.new(V, B)
UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
UserInputService.MouseIconEnabled = false
char.HumanoidRootPart.CFrame = CFrame.new(char.HumanoidRootPart.Position, nearestPart.Position)
run.RenderStepped:Wait()
end
end)
I’ve spent hours trying out different stuff but it all would still end up spazzing out in the end.
It would be much appreciated if you could help me with this.