multifora0
Multifora0НЕ ИСПОЛЬЗУЙТЕ ИИ, ОН БУДЕТ ГОВОРИТЬ ЧТО СКРИПТ ПРАВИЛЬНЫЙ!
Сам скрипт такой:
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 выдает такую ошибку:
Как сделать чтобы при нажатии на ProximityPrompt Npc следовал за игроком, и чтобы когда Npc
касается игрока, игрок умирал? + надо сделать так чтобы после смерти Npc не ходил за игроком.
Я уже пробовал скрипт ниже (сам написал), но Npc как то странно следует за игроком.
local prompt = workspace.PromptHolder.ProximityPrompt
local Npc = script.Parent
local Humanoid = Npc.Humanoid
prompt.TriggerEnded:Connect(function(plr)
local findedplr = workspace:FindFirstChild( plr.Name )
while wait() do
if Humanoid.Health == 0 then return else
Humanoid:MoveTo(findedplr.Head.Position)
end
end
end)
Помогите плз