local PathfindingService = game:GetService("PathfindingService")
local prompt = workspace.Atm500.PromptHolder.ProximityPrompt
local npc = script.Parent
local humanoid = npc:FindFirstChildOfClass("Humanoid")
local player = nil
prompt.Triggered:Connect(function(plr)
player = plr
while humanoid and humanoid.Health > 0 do
if player and player.Character then
local path = PathfindingService:CreatePath({
AgentRadius = 2,
AgentHeight = 5,
AgentCanJump = true,
AgentJumpHeight = 10,
AgentMaxSlope = 45,
})
-- Вычисляем путь к игроку
path:ComputeAsync(npc.HumanoidRootPart.Position, player.Character.HumanoidRootPart.Position)
-- Ждем завершения движения по пути
while path.Status ~= Enum.PathStatus.Success do
path.Blocked:Wait()
end
end
wait(1)
end
end)
npc.HumanoidRootPart.Touched:Connect(function(hit)
local playerHumanoid = hit.Parent:FindFirstChildOfClass("Humanoid")
if playerHumanoid then
playerHumanoid.Health = 0
end
end)
попробуй так, не проверял так что не гарантирую то что будет работать
Сам скрипт такой:
local PathfindingService = game:GetService("PathfindingService")
local prompt = workspace.Atm500.PromptHolder.ProximityPrompt
local npc = script.Parent
local humanoid = npc:FindFirstChildOfClass("Humanoid")
local player = nil
prompt.Triggered:Connect(function(plr)
player = plr
while humanoid and humanoid.Health > 0 do
if player and player.Character then
local path = PathfindingService:CreatePath({
AgentRadius = 2,
AgentHeight = 5,
AgentCanJump = true,
AgentJumpHeight = 10,
AgentMaxSlope = 45,
})
-- Вычисляем путь к игроку
path:ComputeAsync(npc.HumanoidRootPart.Position, player.Character.HumanoidRootPart.Position)
path:MoveToFinished:Wait() -- Ждем завершения движения по пути
end
wait(1)
end
end)
npc.HumanoidRootPart.Touched:Connect(function(hit)
local playerHumanoid = hit.Parent:FindFirstChildOfClass("Humanoid")
if playerHumanoid then
playerHumanoid.Health = 0
end
end)
Output выдает такую ошибку: