Top.Mail.Ru
Ответы
Аватар пользователя
9мес
Изменено
Аватар пользователя
Аватар пользователя
Программирование
+1

Roblox Studio. Помогите исправить скрипт от ИИ.

НЕ ИСПОЛЬЗУЙТЕ ИИ, ОН БУДЕТ ГОВОРИТЬ ЧТО СКРИПТ ПРАВИЛЬНЫЙ!
Сам скрипт такой:
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 выдает такую ошибку:

По дате
По рейтингу
Аватар пользователя
Ученик
9мес
1234567891011121314151617181920212223242526272829303132333435
 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)  

попробуй так, не проверял так что не гарантирую то что будет работать