robocu3
|
  |
| Joined: 13 Mar 2009 |
| Total Posts: 6485 |
|
|
| 30 Jun 2012 06:36 PM |
So I made a script that when you walk infront of this zombie and he sees you, he goes after you.
function getAngle(part) local v = part.Position - script.Parent.Zombie.Head.Position local a1 = math.acos( v:Dot(script.Parent.Zombie.Head.CFrame.lookVector)/v.magnitude ) return a1, v end
function getClosestPlayer() local dist = 5000 local tors = nil for _, v in pairs(game.Players:GetPlayers()) do if v.Character and v.Character:FindFirstChild("Torso") and v.Character:FindFirstChild("Head") and v.Character:FindFirstChild("Humanoid") and v.Character.Humanoid.Health > 0 then local angle, vec = getAngle(v.Character.Head) if math.deg(angle) <= 30 then if vec.magnitude < dist then dist = vec.magnitude tors = v.Character.Torso end end end end return tors end
while true do wait(0.1) local tors = getClosestPlayer() if tors then script.Parent.Zombie:MoveTo(tors.Position, tors) end end --------------------------------------------------------------------- It doesn't work and I don't know why. Any help? -=Robo=- |
|
|
| Report Abuse |
|
|
CombatHe
|
  |
| Joined: 26 May 2012 |
| Total Posts: 23 |
|
|
| 30 Jun 2012 06:38 PM |
because EVERYTHING IS WRONG WITH IT
now go fix mine |
|
|
| Report Abuse |
|
|
|
| 30 Jun 2012 06:57 PM |
Jerk. ----- I honestly don't know what's wrong with the script. D: |
|
|
| Report Abuse |
|
|
robocu3
|
  |
| Joined: 13 Mar 2009 |
| Total Posts: 6485 |
|
|
| 30 Jun 2012 07:23 PM |
Combat, get off this forum if you're not going to help. This is the second post I've seen you do this on. So no help, I'm assuming? -=Robo=- |
|
|
| Report Abuse |
|
|
swmaniac
|
  |
| Joined: 28 Jun 2008 |
| Total Posts: 15773 |
|
|
| 30 Jun 2012 08:51 PM |
| Presumably the output says nothing? |
|
|
| Report Abuse |
|
|
robocu3
|
  |
| Joined: 13 Mar 2009 |
| Total Posts: 6485 |
|
|
| 01 Jul 2012 06:04 PM |
Output doesn't say anything on my PC. o_o -=Robo=- |
|
|
| Report Abuse |
|
|