0 views0 copies0 likes
NPC Look-at-Player with a Range Limit
Universal script
Copy it, then test it in your own Studio place.
Script code
16 lines ยท 0.6 KBlocal Players = game:GetService("Players")local bot = workspace:WaitForChild("GreeterBot")while bot.Parent do local origin = bot:GetPivot().Position local nearest, distance = nil, 22 for _, player in Players:GetPlayers() do local root = player.Character and player.Character:FindFirstChild("HumanoidRootPart") if root then local position = Vector3.new(root.Position.X, origin.Y, root.Position.Z) local gap = (position - origin).Magnitude if gap > 0.5 and gap < distance then nearest, distance = position, gap end end end if nearest then bot:PivotTo(CFrame.lookAt(origin, nearest)) end-- โฆopen Get script for the full sourceAbout this script
Anchor a display rig named GreeterBot and put it where visitors will walk past. This server script checks for the nearest player within 22 studs about five checks each second and rotates the model on the horizontal plane. The character keeps its original position and ignores visitors outside the range. Leave a small dead zone around the pivot to avoid jitter when someone overlaps the rig.
Log in to leave a comment.
No comments yet
Be the first to share your thoughts!
Comments
Share what works, ask questions, or report an issue.