Mouse.Hit blacklist does not work

Hello everyone, I have a script that makes the player face the mouse:

mouse.TargetFilter = game.Workspace
game.ReplicatedStorage.Play.Event:Connect(function()
	local character = Player.Character or Player.CharacterAdded:Wait()
	
	while character:FindFirstChild("Humanoid").Health > 0 do
		game:GetService("RunService").Stepped:Wait()
		character.UpperTorso.CFrame = CFrame.new(character.UpperTorso.Position, Vector3.new(mouse.Hit.p.X, character.UpperTorso.Position.Y, mouse.Hit.p.Z))
	end
end)

However, I don’t want it to interfere with hitboxes, so I added

mouse.TargetFilter = game.Workspace

There is terrain under it, so it should work fine.
However, it doesn’t. Below is a video of what happens:
Also, if I remove the TargetFilter code, it works fine apart from hitboxes interfering with it.

1 Like

mouse.TargetFilter = game.Workspace would filter the ‘Workspace’ container and every physical instance contained within it (effectively blacklisting the entire 3D environment). If you want to filter hitboxes specifically I’d recommend grouping them together inside a single folder and blacklisting that instead, i.e;
mouse.TargetFilter = hitboxFolder