bretty167
|
  |
| Joined: 14 Nov 2008 |
| Total Posts: 245 |
|
|
| 08 Sep 2011 11:10 AM |
I have this script, that I made (Took a while to find the right bits, as I am a beginner at this), which is desgined to Attack the nearest torso, Could anyone change this script for me, so that it only attacks Players?
function findNearestTorso(pos) local list = game.Workspace:children() local torso = nil local dist = 60 local temp = nil 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 game.Players:findFirstChild(human.Parent.Name) ~= nil then
if (temp.Position - pos).magnitude < dist then torso = temp dist = (temp.Position - pos).magnitude end end
if game.Players:findFirstChild(human.Parent.Name) == nil then
if (temp.Position - pos).magnitude < dist then torso = temp dist = (temp.Position - pos).magnitude end end
end end end
return torso end
|
|
|
| Report Abuse |
|
|
| |
|
bretty167
|
  |
| Joined: 14 Nov 2008 |
| Total Posts: 245 |
|
|
| 08 Sep 2011 11:16 AM |
| It's not a request, I was asking if anyone could help me change a script so that it does somthing slightly different, A request is when someone asks you t make something COMPLETELY. |
|
|
| Report Abuse |
|
|
Fl0xData
|
  |
| Joined: 01 Aug 2011 |
| Total Posts: 18 |
|
|
| 08 Sep 2011 11:21 AM |
No. You request us to change the script to something you didn't even attempt to try. Thats; Lazy Racist (and) Slavery. |
|
|
| Report Abuse |
|
|
bretty167
|
  |
| Joined: 14 Nov 2008 |
| Total Posts: 245 |
|
|
| 08 Sep 2011 11:28 AM |
I'm going to ignore you fl0x, Because all you've really done on this forum Is rip off other people on mistakes. Anyway, Is it possible to do Findnearestplayer()?, Or Just Torso? |
|
|
| Report Abuse |
|
|
bretty167
|
  |
| Joined: 14 Nov 2008 |
| Total Posts: 245 |
|
|
| 08 Sep 2011 11:30 AM |
I beleive I have fixed it, (Unless it still attacks other AI's, which I have not yet tested)
function findNearestPlayer(pos) local list = game.Workspace:children() local torso = nil local dist = 60 local temp = nil 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
|
|
|
| Report Abuse |
|
|
bretty167
|
  |
| Joined: 14 Nov 2008 |
| Total Posts: 245 |
|
|
| 08 Sep 2011 11:39 AM |
Nope... They still attack each other... Can anyone tell me How the local list= could be changed so that it doesn't find an AI? |
|
|
| Report Abuse |
|
|