local monster = script.Parent local player = game.Players.LocalPlayer local character = player.Character local hum = character:WaitForChild("Humanoid") local root = character:WaitForChild("HumanoidRootPart") function findClosestPlayer() local closestPlayer = nil local closestDistance = math.huge for i, v in ipairs(game.Players:GetPlayers()) do if v ~= player then local vChar = v.Character if vChar then local vRoot = vChar:WaitForChild("HumanoidRootPart") local distance = (root.Position - vRoot.Position).Magnitude if distance < closestDistance then closestPlayer = v closestDistance = distance end end end end return closestPlayer end function chasePlayer(playerToChase) local playerRoot = playerToChase.Character:WaitForChild("HumanoidRootPart") local targetDirection = (playerRoot.Position - root.Position).Unit local moveDirection = CFrame.new(root.Position, root.Position + targetDirection) * CFrame.Angles(0, math.rad(90), 0) monster:MoveTo(moveDirection) end while wait() do local closestPlayer = findClosestPlayer() if closestPlayer then chasePlayer(closestPlayer) end end