Город МОСКОВСКИЙ
00:00:53

Как сделать так что бы НПС всегда смотрел на игрока в Ro

Аватар
Gaming Sanctuary
Просмотры:
142
Дата загрузки:
01.06.2025 19:06
Длительность:
00:00:53
Категория:
Лайфстайл

Описание

Скрипт из видео:


local npc = script.Parent
local head = npc:FindFirstChild("Head")
local humanoidRootPart = npc:FindFirstChild("HumanoidRootPart")

if not head or not humanoidRootPart then
warn("У NPC отсутствует голова или HumanoidRootPart!")
return
end


local function lookAtPlayer()
for _, player in pairs(game.Players:GetPlayers()) do
local character = player.Character
if character and character:FindFirstChild("HumanoidRootPart") then
local playerPosition = character.HumanoidRootPart.Position
local npcPosition = humanoidRootPart.Position


local lookVector = (playerPosition - npcPosition).unit
humanoidRootPart.CFrame = CFrame.new(npcPosition, npcPosition + lookVector)
end
end
end


game:GetService("RunService").Heartbeat:Connect(lookAtPlayer)

Рекомендуемые видео