You can write your topic however you want, but you need to answer these questions:
What do you want to achieve?
I would like to make when I clicked the NPC’s torso, my character looks at it.
What is the issue? - YouTube
It seemed to glitch out when I move.
What solutions have you tried so far?
I tried replacing while true do with while wait(.1) do but it didn’t work.
script:
script.Parent.ClickDetector.MouseClick:Connect(function(plr)
local char = plr.Character
local humrp = char.HumanoidRootPart
local part = script.Parent
while true do
humrp.CFrame = CFrame.lookAt(humrp.Position, Vector3.new(part.Position.X, humrp.Position.Y, part.Position.Z))
end
end)
Try looking at this there will be explained how you can do it: CFrames | Roblox Creator Documentation
If it still doesn’t work try to print your variables to see if they exist.
script.Parent.ClickDetector.MouseClick:Connect(function(plr)
local char = plr.Character or plr.CharacterAdded:Wait()
local humrp = char.HumanoidRootPart
local part = script.Parent
humrp.Anchored = true
humrp.CFrame = CFrame.lookAt(humrp.Position, Vector3.new(part.Position.X, humrp.Position.Y, part.Position.Z))
end)
and unanchor the humrp when you want it to lock off
local part = script.Parent
part.ClickDetector.MouseClick:Connect(function(plr)
local char = plr.Character
local hmr = char:WaitForChild("HumanoidRootPart")
while task.wait() do
hmr.CFrame = CFrame.lookAt(hmr.Position, part.Position)
end
end)