local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
local char = script.Parent
local torso = char:WaitForChild("Torso")
local hrp = char:WaitForChild("HumanoidRootPart")
local humanoid: Humanoid = char:WaitForChild("Humanoid")
local function getmousepos()
local ignoreList = {}
local lookup = {}
for _, hum in workspace:GetDescendants() do
if hum:IsA("Humanoid") and not lookup[hum.Parent] then
lookup[hum.Parent] = true
table.insert(ignoreList, hum.Parent)
end
end
local params = RaycastParams.new()
params.FilterDescendantsInstances = ignoreList
params.FilterType = Enum.RaycastFilterType.Exclude
local result = workspace:Raycast(torso.Position--[[workspace.CurrentCamera.CFrame.Position]], workspace.CurrentCamera.CFrame.LookVector * 10000, params)
return result and result.Position or mouse.Hit.Position
end
game:GetService("RunService").RenderStepped:Connect(function()
if not plr:GetAttribute("MouseLockEnabled") then return end
local mousePos = getmousepos()
local direction = (mousePos - torso.Position).unit
local targetCFrame = CFrame.new(torso.Position, torso.Position + direction)
local rx, ry, rz = targetCFrame:ToOrientation()
hrp.RootJoint.C1 = CFrame.Angles(-rx, -ry, -rz)
end)
This is my current script. I’m trying to modify the RootJoint of the HumanoidRootPart to rotate the torso, because if I tried to use CFrame it would result in the HumanoidRootPart also rotating, and I don’t want that because I disabled collissions on torso so that it doesnt collide with the ground when the player moves his camera.
Also, if it helps, my character is a custom character.

