I'm making a script where when the player gets near the NPC, the NPC looks at the player. It works but I want it to ignore the Y and X axis.
script.Parent.Touched:connect(function(Char)
local Humanoid = Char.Parent:FindFirstChild("Humanoid")
if Humanoid ~= nil then
local torso = Char.Parent:FindFirstChild("HumanoidRootPart")
while wait() do
script.Parent.Parent.HumanoidRootPart.CFrame = CFrame.new(script.Parent.Parent.HumanoidRootPart.Position, torso.Position)
end
end
end)
How do I go about doing this?

2 comments
It works in Studio but in-game, it just disappears
Nvm fixed it tysm