HumanoidRootPart not rotating towards object properly

Hello!
Lately I’ve been having a few issues with CFrame.
My goal is to have the top face of my players HumanoidRootPart consistently rotate towards an object (or swinging point) similar to the way Spider-Man does in the PS4 and PS5 games.

My current Code:

‘’‘RunService.RenderStepped:Connect(function(rotate)
if keyDown == true then
if not humanoidRootPart:FindFirstChild(“BodyGyro”) then
Gyro = Instance.new(“BodyGyro”, humanoidRootPart)
local lookAt = part.CFrame.Position
Gyro.CFrame = CFrame.new(humanoidRootPart.Position,
humanoidRootPart.CFrame.upVector + lookAt) * CFrame.Angles(0,0,math.rad(160))
end
if Gyro ~= nil then
if Gyro.Name ~= nil then
local lookAt = part.CFrame.Position
Gyro.CFrame = CFrame.new(humanoidRootPart.Position,
humanoidRootPart.CFrame.upVector + lookAt) * CFrame.Angles(0,0,math.rad(160))
end
end
end
end)’’’

This is the product I am getting:

I really appreciate all the help!
Thanks in advance,
staramlord

1 Like

try reference humanoidRootPart.CFrame

RunService.RenderStepped:connect(function()
	humanoidRootPart.CFrame= CFrame.lookAt(part.Position)
end)

Hello!

When I enter the same Code I receive an error in the output:

23:02:40.255 Workspace.staramlord.Web Swing 1.0 (Raycast):156: missing argument #2 to ‘lookAt’ (Vector3 expected) - Client - Web Swing 1.0 (Raycast):156

I dont have much experience with CFrame.lookAt, could you explain to me how it is supposed to work a bit more in depth?

sorry, I forgot something!

RunService.RenderStepped:connect(function()
	humanoidRootPart.CFrame= CFrame.lookAt(humanoidRootPart.Position,part.Position)
end)

Hello again!
Now its starting to work a bit, but its not quite what I’m looking for. My goal is for the humanoidRootParts top face to consistently face the parts position. What you recommended appears to have the humanoidRootParts lookVector face the same direction as the parts position.

Can you show me exactly what you want to do? A visual look will probably help me come up with something!

Hello!
I apologize for the late response but this is what I mean:

https://youtu.be/mU05uO-0Vec

Lol, I know that I seem a bit confusing, sorry. Notice how the humanoid is rotated so that its top face always rotates towards the web swinging point, that is the product i am trying to achieve.

1 Like