Why does my body SLOWLY but SURELY inch forward with this script

-- this happens every renderstpped
Humanoid.AutoRotate = false
local pos = Root.Position
Root.CFrame = CFrame.new(pos)

it’s pretty simple to tell what this script is SUPPOSED to do but instead it SLOWLY makes my little HUMANOID inch forward and I have no idea why

for some reason my root thinks it’s neccessary to just “follow” my cameras movements in terms of rotation too which makes 0 sense

It’s because your setting the Pos to the same position each frame

yeah but that shouldn’t make it go forward and that’s how this post does it (basically) and it used to not do this

but I will try a different method

I’m not really sure about internals but maybe it’s something to do with rounding?

Like when you save the current position, it’s actually a really precise floating point number but it’s rounded up.

That’s all that I could possibly think of

1 Like

You want your character to look at your mouse ?

this could be true so I did this instead


no I was just looking at that post anyway I want my character to look at camera lookvector + root position (same Y as root)

1 Like

wait I forgot to actually reply this is whaat I did

local pos = Root.CFrame.Position
		local cpos = Camera.CFrame.LookVector*10
	Root.CFrame = CFrame.lookAt(pos, pos + Vector3.new(cpos.X, 0, cpos.Z))

it still makes me inch slitgly slower

1 Like

Yeah honestly I don’t have any clue either. Shouldn’t be moving you at all according to that code snippet

1 Like

local cam = workspace.CurrentCamera
local hrp = char.HumanoidRootPart

local wantPos = hrp.Position + vector3.new(cam.CFrame.LookVector.X, 0, cam.CFrame.LookVector.Z)

hrp.CFrame = CFrame.new(hrp.Position, wantPos)

Try this also sorry abt the errors I’m on mobile

1 Like

Perhaps try smoothing it a bit with lerp:

local Camera = game:GetService("Workspace").CurrentCamera
local Character = game:GetService("Players").LocalPlayer.Character
local Root = Character.HumanoidRootPart

game:GetService("RunService").RenderStepped:Connect(function()
	local look = Root.Position + Vector3.new(Camera.CFrame.LookVector.X, 0, Camera.CFrame.LookVector.Z)
	Root.CFrame = Root.CFrame:lerp(CFrame.new(Root.Position, look), 0.5)
end)

Edit: changing the lerp rate from 0.5 to 0.1 makes a really smooth turning animation.

local wantPos = Root.Position + Vector3.new(Camera.CFrame.LookVector.X, 0, Camera.CFrame.LookVector.Z)
		Root.CFrame = CFrame.new(Root.Position, wantPos)

yeah I did that and it still inches me forward I don’t know if this is a roblox bug or something at this point

Can you send a video of this happening ?

Here’s a rewritten, alternative approach using a BodyGyro, instead of altering the CFrame directly:

local camera = game:GetService("Workspace").CurrentCamera
local player = game:GetService("Players").LocalPlayer
local character = player.Character
local root = character.HumanoidRootPart

character.Humanoid.AutoRotate = false

local gyro = Instance.new("BodyGyro")
gyro.MaxTorque = Vector3.new(0, math.huge, 0)
gyro.P = 10000
gyro.D = 200
gyro.CFrame = root.CFrame
gyro.Parent = root

game:GetService("RunService").RenderStepped:connect(function()
	local lookDirection = camera.CFrame.LookVector
	local flatDirection = Vector3.new(lookDirection.X, 0, lookDirection.Z).Unit
	local targetRotation = CFrame.new(Vector3.zero, flatDirection)

	gyro.CFrame = CFrame.new(root.Position) * CFrame.Angles(0, math.atan2(-flatDirection.X, -flatDirection.Z), 0)
end)
1 Like

normally I would but I have to go quickly basically it would just make me face the correct direction but would move me forward like 0.01 studs every frame


my pc has 2 fps anyway yeah I just used this method


this probably would’ve worked too but I tried the gyro method and so far it works plus it’s customizable which is nice


anyway thanks for the help to eveyone

Also, it seems in my old games where this used to happen, it does not happen anymore. Now I’m actually sure this was a random Roblox bug or toggle that got fixed when Studio updated.

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