I have an npc that uses a bodygyro’s CFrame to aim at the player.
but periodically it just stops rotating and becomes unresponsive, I tried making the Y axis INF, I tried making every part as light as possible, and I tried getting rid of friction for both the NPC and the baseplate, but not matter what it wont rotate again UNLESS I move it up a little with the studio tools:
(excuse the quality as I had to use an online GIF converter)
it was rotating before getting stuck so its not anchored or welded in any way.
is there a way to fix this? I want to use a bodygyro mover so that it moves smoothly unlike using CFrame.
function aim()
if script.Parent.Parent.IsAttacking.Value == true then
local t = script.Parent.Parent.Target.Value
if t then
local c = script.Parent.Parent.Parent.Parent.Center
if c then
c.BodyAim.CFrame = CFrame.new(c.Position,t.Position)
end
end
end
end
while true do
wait(0.1)
aim()
end
the characters torso is in an object value. and all the script really does is set the body gyro’s CFrame to the torso’s position.
I should have mentioned that my npc is non-humanoid, but thats ok because what you provided does help me go in the right direction so im just gonna go ahead and mark it as the solution. but I do have one last question.
in your code your getting the children of the workspace in order to use .Magnitude for the npc’s range.
if there are a lot of objects in the workspace will this cause performance problems?