| |
|
Vescatur
|
  |
| Joined: 18 Feb 2012 |
| Total Posts: 3426 |
|
| |
|
| |
|
|
| 08 Aug 2014 04:50 PM |
| Well I want to make it to where if you "black out" you teleport to the nearest hospital. |
|
|
| Report Abuse |
|
|
Miro034
|
  |
| Joined: 07 Oct 2009 |
| Total Posts: 6568 |
|
|
| 08 Aug 2014 04:50 PM |
| You could probably use those codes in zombies where it detects the nearest character. You could possibly do this by editing when the zombie detects a humanoid where instead you can make it so if the player detects bricks with values inside them so check if they are the 'brick' then it will return a function. |
|
|
| Report Abuse |
|
|
Vescatur
|
  |
| Joined: 18 Feb 2012 |
| Total Posts: 3426 |
|
|
| 08 Aug 2014 04:52 PM |
| I'd personally use a localscript and do a DistanceFromCharacter() event when they die to see which one is closer. |
|
|
| Report Abuse |
|
|
Miro034
|
  |
| Joined: 07 Oct 2009 |
| Total Posts: 6568 |
|
|
| 08 Aug 2014 04:59 PM |
@Ves
I learnt something from j00 now. I never heard DistanceFromCharacter() before. :/ |
|
|
| Report Abuse |
|
|
Ragnarope
|
  |
| Joined: 12 Jul 2014 |
| Total Posts: 3852 |
|
|
| 08 Aug 2014 05:06 PM |
(Character.Torso.Position - brick.Position).magnitude
-ForeverDev [ R$14,435 / 2,500,000 ] |
|
|
| Report Abuse |
|
|
Miro034
|
  |
| Joined: 07 Oct 2009 |
| Total Posts: 6568 |
|
|
| 08 Aug 2014 05:08 PM |
@rag
Looks like you used that code from this source: http://www.roblox.com/Forum/ShowPost.aspx?PostID=121001053
(Scroll down to find it) |
|
|
| Report Abuse |
|
|
Ragnarope
|
  |
| Joined: 12 Jul 2014 |
| Total Posts: 3852 |
|
|
| 08 Aug 2014 05:14 PM |
I didn't, that's just how you would do it.
You make a function that takes a table parameter, then pass all the bricks into the function as a table, and the closest brick would be returned
function getCloseBrick(bricks, player) if not player.Character then return false end local pos = player.Character.Torso.Position local nearest; for i, v in pairs(bricks) do if not nearest then nearest = (pos - v.Position).magnitude elseif (pos - v.Postion).magnitude < nearest then nearest = (pos - v.Position).magnitude end end return nearest end
--you could then pass the children of a model into the function, with the player
local closestBrick = getCloseBrick(Workspace["model name"]:GetChildren(), game.Players.Ragnarope)
-ForeverDev [ R$14,435 / 2,500,000 ] |
|
|
| Report Abuse |
|
|