Veerk
|
  |
| Joined: 20 Jun 2012 |
| Total Posts: 1597 |
|
|
| 22 Jul 2012 02:52 PM |
local parts = game.Workspace.Map:getChildren() for i = 1,#parts do if (parts[i].Name ~= "Wall") then if (parts[i].Name ~= "Water") then if (parts[i].ClassName ~= "Model") then if (parts[i].Position.Magnitude =< 8) then script.Parent:MoveTo(parts[i]) end end end end end
Output doesn't say anything.
I just want it to move to whatever block is within 8 studs or whatever |
|
|
| Report Abuse |
|
|
adark
|
  |
| Joined: 13 Jan 2008 |
| Total Posts: 6412 |
|
|
| 22 Jul 2012 02:56 PM |
| You subtract two Vector3 values to find their Magnitude, as it compares the distance of the Position from (0, 0, 0). |
|
|
| Report Abuse |
|
|
Veerk
|
  |
| Joined: 20 Jun 2012 |
| Total Posts: 1597 |
|
|
| 22 Jul 2012 02:56 PM |
| Oh I was looking at free models to see what magnitude was and all I see is magnitude so I thought it was a property of position |
|
|
| Report Abuse |
|
|
Veerk
|
  |
| Joined: 20 Jun 2012 |
| Total Posts: 1597 |
|
|
| 22 Jul 2012 02:57 PM |
So you mean to just
block.Position - block.Position??? |
|
|
| Report Abuse |
|
|
sam6175
|
  |
| Joined: 16 Aug 2008 |
| Total Posts: 1391 |
|
|
| 22 Jul 2012 02:58 PM |
local check = script.Parent.Part local parts = game.Workspace.Map:GetChildren() for i = 1,#parts do if (parts[i].Name ~= "Wall") and (parts[i].Name ~= "Water") and (parts[i].ClassName ~= "Model") then if (parts[i].Position - check.Position).magnitude <= 8 then script.Parent:MoveTo(parts[i]) end end end
change check to whatever part you want to check the magnitude from.
|
|
|
| Report Abuse |
|
|
Veerk
|
  |
| Joined: 20 Jun 2012 |
| Total Posts: 1597 |
|
| |
|
Veerk
|
  |
| Joined: 20 Jun 2012 |
| Total Posts: 1597 |
|
|
| 22 Jul 2012 03:12 PM |
Ok so sam, I ran into another problem (Sorry, I am trying to figure things out)
I realized there are many objects around it. (I made it so they turn red) I want it to single it out..
I try doing a math.random to choose one but that keeps saying I am attempting to get length of field?
local check = script.Parent.Parent.Stand local parts = game.Workspace.Map:GetChildren() for i = 1,#parts do if (parts[i].Name == "GameBlock") and (parts[i].ClassName ~= "Model") then if (parts[i].Position - check.Position).magnitude <= 16 then s = math.random(1,#parts[i]) end end end
if s == 1 then s.BrickColor = BrickColor.new("Bright red") end
|
|
|
| Report Abuse |
|
|
Veerk
|
  |
| Joined: 20 Jun 2012 |
| Total Posts: 1597 |
|
|
| 22 Jul 2012 03:17 PM |
| wait im an idiot i see my error |
|
|
| Report Abuse |
|
|
Veerk
|
  |
| Joined: 20 Jun 2012 |
| Total Posts: 1597 |
|
|
| 22 Jul 2012 03:21 PM |
agagagag ook I am so lost.
This is my new script
local check = script.Parent.Parent.Stand local parts = game.Workspace.Map:GetChildren() for i = 1,#parts do if (parts[i].Name == "GameBlock") and (parts[i].ClassName ~= "Model") then if (parts[i].Position - check.Position).magnitude <= 16 then script.Parent.Parent:MoveTo(Vector3.new(math.random(1,#parts))).Position end end end
Says I am missing an = at line 8 (Which is an end)
what |
|
|
| Report Abuse |
|
|
|
| 22 Jul 2012 03:27 PM |
| 1337777777777777777777777777777777777777777777777777777777777777 |
|
|
| Report Abuse |
|
|
Veerk
|
  |
| Joined: 20 Jun 2012 |
| Total Posts: 1597 |
|
|
| 22 Jul 2012 03:38 PM |
| You increased my hopes... and dropped them. |
|
|
| Report Abuse |
|
|