(Sorry in advance because I’m new in programming)
So basically I get some kiilbrick from the toolbox that has this script:
--Variables--
local Brick = script.Parent
--End--
--Code--
local function PlayerTouched(Part)
local Parent = Part.Parent
if game.Players:GetPlayerFromCharacter(Parent) then
Parent.Humanoid.Health = 0
end
end
Brick.Touched:connect(PlayerTouched)
My problem is how to convert those for NPC killing only?
The NPC are group in one as Killers, So I created a for Loop
to identify all of the children of killers.
This is what I make:
local Brick = script.Parent
local killers = game.Workspace:WaitForChild("Killers"):GetChildren()
local function EnemyTouched(Part)
local Parent = Part.Parent
for i, thisOne in pairs(killers) do
--As you can see this is blank because I don't know what's next I will do.
--Also all of the killer's humanoid named as Zombie.
--So the function of this script should have ..Zombie.Health = 0
end
end
Brick.Touched:Connect(EnemyTouched)