local Players = game:GetService("Players")
local PathfindingService = game:GetService("PathfindingService")
local NPC = script.Parent
local ProximityPrompt = NPC:WaitForChild("ProximityPrompt")
local function followPlayer(player)
local character = player.Character
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
while true do
local path = PathfindingService:CreatePath({
AgentRadius = 2,
AgentHeight = 5,
AgentCanJump = true,
AgentJumpHeight = 10,
AgentMaxSlope = 45,
})
path:ComputeAsync(NPC.Position, humanoidRootPart.Position)
-- Используем метод :MoveTo для NPC
path:MoveTo(NPC)
-- Ждем завершения пути
path:MoveToFinished:Wait()
wait(1)
if (NPC.Position - humanoidRootPart.Position).Magnitude < 5 then
-- Убийство игрока
local humanoid = character:FindFirstChild("Humanoid")
if humanoid then
humanoid:TakeDamage(10) -- Урон при касании
end
break
end
end
end
ProximityPrompt.Triggered:Connect(followPlayer)
Отредактировал код ещё раз попробуйте
Можете пожалуйста не использовать ии?