|
| 01 Jun 2015 08:38 PM |
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 = 1000 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 -8 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
and I put them in a person to make em walk. Then I copied the person 5 times and my game lags badly! Does anyone know how to make it not lag?
(yes its a free model script)
(yes im bad at scripting)
|
|
|
| Report Abuse |
|
|
|
| 01 Jun 2015 08:39 PM |
| Ugh the other script I cant post it gives me an error |
|
|
| Report Abuse |
|
|
| |
|
|
| 01 Jun 2015 09:08 PM |
| Side note: Did you copy and paste this? or sections of it? |
|
|
| Report Abuse |
|
|
|
| 01 Jun 2015 09:11 PM |
I copied and pasted 1 entire whole script
but i cant paste the other script |
|
|
| Report Abuse |
|
|
| |
|
| |
|
CrowClaws
|
  |
| Joined: 04 Jul 2010 |
| Total Posts: 4466 |
|
|
| 01 Jun 2015 09:24 PM |
| it's bc ur using freemodels and it probs has a virus |
|
|
| Report Abuse |
|
|
|
| 01 Jun 2015 09:48 PM |
| Well I dont c a virus script thinger in the model |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 01 Jun 2015 10:24 PM |
| its called using too many loops |
|
|
| Report Abuse |
|
|