For example, a game presented a big head with eyes, where ever the player move, the eyes will stair at the player. For like a security camera, it moves as the player moves.
Use the constructor CFrame.new (Vector3 position, Vector3 point) It makes an object point toward a given point which can be the nearest player. For example:
local pos1= game.Players.LocalPlayer.Character.Head local pos2 = game.Workspace.Part1 pos1.CFrame = CFrame.new(pos1.Position,pos2.Position)
or --//game.Players.LocalPlayer.Character.Head.CFrame = CFrame.new(game.Players.LocalPlayer.Character.Head, game.Workspace.Part1.Position)
If you want a working script I will make it.
local part = Instance.new("Part",workspace); -- part for test part.Anchored = true part.CFrame = CFrame.new(0,10,0) -- sets part CFrame local function getClosest(max) -- checks closest Humanoid and assumes it has a head. for i,v in pairs(workspace:GetChildren()) do if v:IsA("BasePart") and v:FindFirstChild("Humanoid") and v:FindFirstChild("Humanoid").Parent:FindFirstChild("Head") then dis = (part.Position - v.Position).magnitude if dis <= max then return v end end end end spawn(function() while wait() do part.CFrame = CFrame.new(part.Position,getClosest(60).Position) -- makes part turn to person's head within 60 studs end)