I'm currently doing this, which works fine;
while true do wait() local plr = playerValue.Value if plr then local direction = (plr.Character.Torso.Position - bot.Torso.Position) * Vector3.new(1, 0, 1) bot.Torso.CFrame = CFrame.new(bot.Torso.Position,bot.Torso.Position + direction) end end
with playerValue
being an ObjectValue equal to the correct player.
However, with lots of NPCs this causes lots of lag. The Script Performance window shows that this is very inefficient, on a large scale at least.
Do you know any more efficient method of making the bot face your character?
You could use the changed method:
playerValue.Value.Character.Torso.Changed:connect(function(property) if string.lower(property) == "position" then local direction = (playerValue.Value.Character.Torso.Position - bot.Torso.Position) bot.Torso.CFrame = CFrame.new(bot.Torso.Position,bot.Torso.Position + direction) end end)
I'm not sure if this would be considered more efficient, but it wouldn't cause lag if the player isn't moving.