Roblox Studio Как сделать что бы киллер нпс убивал и преследовал только игроков
Roblox Studio создал нпс с 2 скриптами-следовать и убивать начал проверять и он еще атакует других нпс киллеров. Как это убрать?
Что бы он не убивал других нпс, надо для всех нпс добавить идентификатор, например, поместить в нпс BoolValue или StringValue или что-нибудь ещё, и назвать это "BOT", а в скриптах проверять есть ли там этот идентификатор с названием "BOT", если есть, то не преследовать и не есть так как это бот, если идентификатора нету, то преследовать и хавать игрока.
нужна моделька и нужно создать скрипт в который вписать данный ниже текст (если что можно сделать всё в одном скрипте )
скрипт на преследование
local larm = script.Parent:FindFirstChild("Left Arm")
local rarm = script.Parent:FindFirstChild("Right Arm")
function findNearestTorso(pos)
local list = game.Workspace:children()
local torso = nil
local dist = 10000000000 --Во сколько будет обноружатся игрок (дистанция)
local temp = nil
local human = nil
local temp2 = nil
for x = 1, #list do
temp2 = list[x]
if (temp2.className == "Model") and (temp2 ~= script.Parent) then
temp = temp2:findFirstChild("Head")
human = temp2:findFirstChild("Humanoid")
Friend = temp2:findFirstChild("Friend")
if (temp ~= nil) and (human ~= nil) and (Friend == nil) or (temp ~= nil) and (human ~= nil) and (human.Health > 0) and (Friend.Value ~= script.Parent.Friend.Value) then
if (temp.Position - pos).magnitude < dist then
torso = temp
dist = (temp.Position - pos).magnitude
end
end
end
end
return torso
end
while true do
wait(0.1)
local target = findNearestTorso(script.Parent.Torso.Position)
if target ~= nil then
script.Parent.Humanoid:MoveTo(target.Position, target)
end
end
на убийство
local larm = script.Parent:FindFirstChild("Left Arm")
local rarm = script.Parent:FindFirstChild("Right Arm")
function findNearestTorso(pos)
local list = game.Workspace:children()
local torso = nil
local dist = 300 -- Change this value to distance of detecting you.
local temp = nil
local human = nil
local temp2 = nil
for x = 1, #list do
temp2 = list[x]
if (temp2.className == "Model") and (temp2 ~= script.Parent) then
temp = temp2:findFirstChild("Torso")
human = temp2:findFirstChild("Humanoid")
if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then
if (temp.Position - pos).magnitude < dist then
torso = temp
dist = (temp.Position - pos).magnitude
end
end
end
end
return torso
end
function Hit(hit)
local human = hit.Parent:FindFirstChild("Humanoid")
if human ~= nil then
human.Health = human.Health -10 -- Change this value to dmg of monster.
end
end
larm.Touched:connect(Hit)
rarm.Touched:connect(Hit)
while true do
wait(0.1)
local target = findNearestTorso(script.Parent.Torso.Position)
if target ~= nil then
script.Parent.Zombie:MoveTo(target.Position, target)
end
end
п