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)```
mc7oof
(oof)
October 29, 2022, 5:39pm
#2
How can it rotate two directions at the same time?
mc7oof
(oof)
October 29, 2022, 5:40pm
#4
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
mc7oof
(oof)
October 29, 2022, 5:42pm
#6
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”.
DasKairo
(Cairo)
October 29, 2022, 5:43pm
#7
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
mc7oof
(oof)
October 29, 2022, 5:43pm
#8
So what would be “forward” to the part?
ill send some screenshots
character limit
the red arrow shows “forward” direction
DasKairo
(Cairo)
October 29, 2022, 5:48pm
#12
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?
DasKairo
(Cairo)
October 29, 2022, 5:52pm
#14
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?
DasKairo
(Cairo)
October 29, 2022, 5:54pm
#16
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)
DasKairo
(Cairo)
October 29, 2022, 5:58pm
#18
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
DasKairo
(Cairo)
October 29, 2022, 6:05pm
#21
Question:
Are you using a local Script or a Server Script?