|
| 24 Mar 2012 05:11 PM |
| How do I make a script that will make a brick go to the closest player? |
|
|
| Report Abuse |
|
|
|
| 24 Mar 2012 05:11 PM |
Insert>Object>Script
-Type code-
VOILA! |
|
|
| Report Abuse |
|
|
|
| 25 Mar 2012 12:16 PM |
| I meant what is the code for it. |
|
|
| Report Abuse |
|
|
dmjoe
|
  |
| Joined: 01 May 2009 |
| Total Posts: 2387 |
|
|
| 25 Mar 2012 12:23 PM |
No requests on this forum.
~According to astronomy, when you wish upon a star; you are actually a few million years late. The star is dead. Just like your dreams.~ |
|
|
| Report Abuse |
|
|
|
| 25 Mar 2012 12:25 PM |
p=game.Players:GetChildren()
function findNearestHead() local lastpos=99999 for i=1,#p do if (script .Parent.Position-p[i].Character.Head.Position).magnitude < lastpos then lastpos=p[i].Character.Head.Position end end return lastpos end
findNearestHead()--this give you the position of Nearest Head |
|
|
| Report Abuse |
|
|
|
| 25 Mar 2012 04:13 PM |
I don't know how to use DragonFang's script so I created my own except all it does is make the brick go to the center of the map
game.Workspace.brick.RocketPropulsion.Target = game.Workspace:findFirstChild("Torso", true) game.Workspace.brick.RocketPropulsion:Fire() |
|
|
| Report Abuse |
|
|
|
| 26 Mar 2012 04:40 AM |
p=game.Players:GetChildren()
function findNearestHead() local lastpos=Instance.new("Part") lastpos.Position=Vector3.new(9999999,999999,9999999) for i=1,#p do if (script .Parent.Position-p[i].Character.Head.Position).magnitude < (script .Parent.Position-lastpos.Position).magnitude then lastpos=p[i].Character.Head end end return lastpos end
game.Workspace.brick.RocketPropulsion.Target = findNearestHead()game.Workspace.brick.RocketPropulsion:Fire() |
|
|
| Report Abuse |
|
|
| |
|
|
| 27 Mar 2012 08:01 AM |
p=game.Players:GetChildren()
function findNearestHead() local lastpos=p[1].Character.Head for i=1,#p do if (script .Parent.Position-p[i].Character.Head.Position).magnitude < (script .Parent.Position-lastpos.Position).magnitude then lastpos=p[i].Character.Head end end return lastpos end
game.Workspace.brick.RocketPropulsion.Target = findNearestHead()game.Workspace.brick.RocketPropulsion:Fire() |
|
|
| Report Abuse |
|
|
|
| 27 Mar 2012 08:03 AM |
| if that didn't work too maybe you could post the errors. |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|