# How can i make a part rotate towards the way its facing infinitely?

i want to make a part rotate towards the player, but still rotating forward infinitely.

this is my code, it faces with the player but it wont rotate forward. how can i make it rotate forward?

``````local direction = humrp.Position + humrp.CFrame.LookVector * humrp.Position.Magnitude

script.Parent.CFrame = CFrame.lookAt(humrp.Position, direction)`````````

How can it rotate two directions at the same time?

i dont know, physics

char limit

I mean I don’t understand how that can happen. So what do you mean?

so the part sticks with the player, and rotates accordingly with the players humanoid root part. it wont rotate forwards, and idk how to calculate its orientation and how to make it rotate forwards

So you mean the position of the part stays with the rotation of the player’s torso, but the part itself rotates by itself and faces “forward”.

``````TS = game:GetService("TweenService")
TS.Create(Part, TweenInfo.new(1), {CFrame = CFrame:LookAt(-Part.Position, humrp.Position}):Play()

``````

`CFrame.LookAt` takes the front of the part and points it at the player. Im a bit confused

So what would be “forward” to the part?

ill send some screenshots

character limit

the red arrow shows “forward” direction

``````while wait() do
Part.CFrame = humrp.CFrame * CFrame.Angles(0,0,0) -- Change this to however you like
end

``````

how can i calculate the CFrame.Angles() direction to rotate it in?

Wdym by calculate? This is all you really need to do, just change the values to whatever you think fits

``````0, -- X
0, -- Y
0 -- Z
``````

wait i fixed it, it goes “forward” but it stops at a certain point. maybe because its reached 90 degrees or something?

It shouldnt, i added a loop so it repeats forever until told to break.

its got an error saying "attempt to index nil with “CFrame” " line 4
`script.Parent.CFrame = humrp.CFrame * CFrame.Angles(0,0,0)`

It means that there is no value in one of the paths, check.

``````repeat wait() until script.Parent.Parent.Parent.Parent.Parent:IsA("Model")
local humrp = script.Parent.Parent.Parent.Parent.Parent:FindFirstChild("HumanoidRootPart")

while wait() do
script.Parent.CFrame = humrp.CFrame * CFrame.Angles(0,0,0)
end
``````

in starterpack and doesnt work

Question:
Are you using a local Script or a Server Script?