Disclaimer (I'm very new to coding within Roblox and 90% of my game code is from the toolbox, and the battledroid I'm using is also from there; hence my being confused on how to fix it)
The Battledroid NPC won't attack me, but will attack a "drooling zombie". All I need for the Battle Droid to do is to follow me because it already does damage upon touching the player, and it will already shoot and damage the player. - - Could other scripts within my game be affecting it's response? I already deleted the spawn protection wall because I thought it might be messing with it. But it's probably the code which I'll add underneath. Thanks for any help!!
(Btw this is the link to the game: https://www.roblox.com/games/4931576856/Star-Wars-The-Citadel-Challenge)
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 = 500 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("Right Arm") 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 human = script.Parent:findFirstChild("Humanoid") if human == nil then human = script.Parent:findFirstChild("Zombie") end while true do wait(1) local target = findNearestTorso(script.Parent.Torso.Position) if target ~= nil then human:MoveTo(target.Position, target) human.TargetPoint = target.Position end end
human = script.Parent:findFirstChild("Humanoid") if human == nil then human = script.Parent:findFirstChild("Zombie") end
it should be a Humaniod at zombie