Equipping a tool glitches players walking backwards

I have a script that rotates the player to face the mouse and a top-down camera.
Shown in the webm below, if I move the player backwards (relative to where they are facing), then they move in a nearly straight line, but once I start equipping + unequipping tools, the player starts to veer off course relative to the mouse’s position.
This only applies to moving backwards. This does not apply to left, right, or forwards. It only starts to occur after I have started equipping / unequipping tools. The tool’s parts are massless and cannot collide.

I am only holding the S button in the webm below.


The mouse needs to be moving from side to side while equipping / unequipping for the bug to be noticed.

There is another variant of the bug where the same movement bug occurs, but only for a few seconds at a time after equipping / unequipping, then reverting to normal movement. I removed a bodyforce object I accidentally hid in my code and this is the bug I’m currently dealing with. I am only holding S yet every time I equip / unequip, I move slightly to the side.

Baseplate_glitch_test.rbxl (46.5 KB)

I need suggestions for work arounds so that I can make my top-down shooter work. For those who do not want to open the .rbxl file, here is the mouse code. It seems that forcing the player to face a certain direction is messing with the tool code

Mouse code:

local char = script.Parent

local RunService = game:GetService("RunService")

local char = script.Parent --player:WaitForChild("Character")
if char == nil then print("WARN-begin: no char") return end
local root = char:WaitForChild("HumanoidRootPart")
if root == nil then print("WARN-begin: no root") return end


function alignPlayer()
	
	local primaryFrame = root.CFrame
	if primaryFrame == nil then print("WARN-begin: no cframe") return end
	
	local player = Players.LocalPlayer
	if player == nil then print("WARN-begin: no player") return end
	local mouse = player:GetMouse()
	
	root.CFrame = (CFrame.new(root.Position, Vector3.new(mouse.Hit.Position.X, primaryFrame.Position.Y,mouse.Hit.Position.Z)))
end



RunService:BindToRenderStep("Mouse", Enum.RenderPriority.Input.Value, alignPlayer)

I can’t seem to reproduce the bug. You should encode the video as H.264 and reupload it as that gif is over 100MB in size.

Thanks, I uploaded it as a webm and it should be displaying properly now

Still cannot reproduce. I added a code that prints when the Z position of the character changes, but it shows nothing. Even tried adding code that produces lag and changing the process priority and still no result.

That’s so weird, so I’m guessing it’s a problem with my settings?

MacOS or Windows? That’s literally the only thing I can think of right now.

Windows. I’ve tried disabling all my plugins.

Are you sure your place is the same as the one you sent here?

Yup. Downloaded it and ran it, the bug in the 2nd webm is happening for me.

oh my god, I published the game and ran it with the roblox player instead of roblox studio and the bug is not happening. That means the bug is strictly on my installation of roblox studio!

I’ve unistalled roblox studio and roblox. I’ve deleted the appdata > local > Roblox file. I’ve logged into studio on an alternative account in case it had something to do with personalized settings. I’ve pressed random keys on my keyboard while walking backwards in case it was an input thing with pressing 2 keys at once with my keyboard. I still have the bug strictly on my installation of Roblox studio. I’m going to sleep for now, but any suggestions would be appreciated.

Something tells me I’m not properly clean installing Roblox Studio