1pie23
|
  |
| Joined: 11 Jul 2010 |
| Total Posts: 1865 |
|
|
| 20 Jun 2012 03:39 PM |
function fire()
local vCharacter = Tool.Parent local vPlayer = game.Players:playerFromCharacter(vCharacter)
local missile = Instance.new("Part")
function findTorsos(pos) local list = game.Workspace.Enemies:GetChildren() local torso = nil local dist = 50 local human = nil
for k,v in pairs(list) do human = v:findFirstChild("Zombie") if human ~= nil then if (v.Torso.Position - pos).Magnitude <= dist then torso = v.Torso end end end
return torso
end
local targets = findTorsos(vCharacter.Torso.Position)
if targets ~= nil then
missile.CFrame = targets.CFrame missile.Size = Vector3.new(10,10,10) missile.Anchored = true missile.BrickColor = BrickColor.new("Dark stone grey") missile.Shape = "Block" missile.Transparency = 0.5 missile.BottomSurface = 0 missile.TopSurface = 0 missile.Name = "Barrage"
local creator_tag = Instance.new("ObjectValue") creator_tag.Value = vPlayer
missile.Parent = game.Workspace
end
end
It works, only that It only goes into the nearest torso, how can I make it clone into ALL torsos within 50 studs? |
|
|
| Report Abuse |
|
|
1pie23
|
  |
| Joined: 11 Jul 2010 |
| Total Posts: 1865 |
|
|
| 20 Jun 2012 03:50 PM |
| Anyone.... MNN... anyone.... |
|
|
| Report Abuse |
|
|
|
| 20 Jun 2012 03:51 PM |
Quite noticeably you didn't make that.
‹‹‹‹ Want to learn to script? http://wiki.roblox.com/index.php/Scripting_Book ›››› |
|
|
| Report Abuse |
|
|
Miro034
|
  |
| Joined: 07 Oct 2009 |
| Total Posts: 6568 |
|
|
| 20 Jun 2012 03:59 PM |
| That is free modelled and edited. By the way lego, is that a new Scripting Book? |
|
|
| Report Abuse |
|
|
Miro034
|
  |
| Joined: 07 Oct 2009 |
| Total Posts: 6568 |
|
|
| 20 Jun 2012 04:01 PM |
| OMG Lego! You made new chapters. I am very eager learning this. This will help me with my project. |
|
|
| Report Abuse |
|
|
1pie23
|
  |
| Joined: 11 Jul 2010 |
| Total Posts: 1865 |
|
|
| 20 Jun 2012 04:04 PM |
| Yeah whatever I took a template. I actually wrote what was in the fire() function. And please lego, if you are going to tell people to learn to script whenever they need help, then get out. |
|
|
| Report Abuse |
|
|
1pie23
|
  |
| Joined: 11 Jul 2010 |
| Total Posts: 1865 |
|
|
| 20 Jun 2012 04:05 PM |
| Anyway, lego go try and find this on free models, nothing will come up. I can tell your on free models all the time so it shouldn't be a problem. |
|
|
| Report Abuse |
|
|
MrNicNac
|
  |
| Joined: 29 Aug 2008 |
| Total Posts: 26567 |
|
|
| 20 Jun 2012 04:08 PM |
function fire() local virtualChar = Tool.Parent local virtualPlay = Game.Players:GetPlayerFromCharacter(virtualChar)
local function gatherEnemies() local toReturn = {} local e = Workspace.Enemies:GetChildren() for i,v in pairs(e) do if v:FindFirstChild("Zombie") then if (v.Torso-virutalChar.Torso.Position).magnitude <= 50 then table.insert(toReturn, v) end end end end for i,v in pairs(gatherEnemies()) do local p = Instance.new("Part") p.CFrame = v.Torso.CFrame p.Size = Vector3.new(10,10,10) p.Anchored = true p.BrickColor = BrickColor.new("Dark stone grey") p.Shape = "Block" p.Transparency = 0.5 p.BottomSurface = 0 p.TopSurface = 0 p.Name = "Barrage" p.Parent = Workspace end end |
|
|
| Report Abuse |
|
|
1pie23
|
  |
| Joined: 11 Jul 2010 |
| Total Posts: 1865 |
|
|
| 20 Jun 2012 04:09 PM |
| Finally, someone who doesn't think they're too cool for everyone and actually helps. Thank you MNN. |
|
|
| Report Abuse |
|
|
MrNicNac
|
  |
| Joined: 29 Aug 2008 |
| Total Posts: 26567 |
|
|
| 20 Jun 2012 04:10 PM |
Yikes, I forgot to tell the script who all the bad people are.
function fire() local virtualChar = Tool.Parent local virtualPlay = Game.Players:GetPlayerFromCharacter(virtualChar)
local function gatherEnemies() local toReturn = {} local e = Workspace.Enemies:GetChildren() for i,v in pairs(e) do if v:FindFirstChild("Zombie") then if (v.Torso-virutalChar.Torso.Position).magnitude <= 50 then table.insert(toReturn, v) end end end return toReturn end for i,v in pairs(gatherEnemies()) do local p = Instance.new("Part") p.CFrame = v.Torso.CFrame p.Size = Vector3.new(10,10,10) p.Anchored = true p.BrickColor = BrickColor.new("Dark stone grey") p.Shape = "Block" p.Transparency = 0.5 p.BottomSurface = 0 p.TopSurface = 0 p.Name = "Barrage" p.Parent = Workspace end end |
|
|
| Report Abuse |
|
|
1pie23
|
  |
| Joined: 11 Jul 2010 |
| Total Posts: 1865 |
|
|
| 20 Jun 2012 04:11 PM |
| Bad people? Legokid must be in that table then. |
|
|
| Report Abuse |
|
|
| |
|
1pie23
|
  |
| Joined: 11 Jul 2010 |
| Total Posts: 1865 |
|
|
| 20 Jun 2012 04:13 PM |
| You spelled "VirtualChar" wrong in the magnitude finder, I fixed it up though. |
|
|
| Report Abuse |
|
|
Miro034
|
  |
| Joined: 07 Oct 2009 |
| Total Posts: 6568 |
|
|
| 20 Jun 2012 04:14 PM |
@pie
Lego is an awesome scripter but not as good as Legend MrNicNac. He's just goofing around (the joke way). |
|
|
| Report Abuse |
|
|
1pie23
|
  |
| Joined: 11 Jul 2010 |
| Total Posts: 1865 |
|
|
| 20 Jun 2012 04:15 PM |
| Also, v.Torso is v.Torso.Position now. And Hi swordphin long time no see. |
|
|
| Report Abuse |
|
|
1pie23
|
  |
| Joined: 11 Jul 2010 |
| Total Posts: 1865 |
|
|
| 20 Jun 2012 04:16 PM |
| Miro yeah that joke was hilarious. Haha just kidding it wasn't now that was funny. |
|
|
| Report Abuse |
|
|
1pie23
|
  |
| Joined: 11 Jul 2010 |
| Total Posts: 1865 |
|
|
| 20 Jun 2012 04:17 PM |
| Well it worked, thanks MNN! I wub going into a pit of enemies and barraging them with smoke :3 |
|
|
| Report Abuse |
|
|
|
| 21 Jun 2012 11:53 AM |
Saying your script is a free model, doesn't make me bad. It makes me observant, and it makes you look stupid trying to PA me.
@guy saying about my book, it's not new as in "brand new", I'm just adding more chapters c:
‹‹‹‹ Want to learn to script? http://wiki.roblox.com/index.php/Scripting_Book ›››› |
|
|
| Report Abuse |
|
|
Miro034
|
  |
| Joined: 07 Oct 2009 |
| Total Posts: 6568 |
|
|
| 21 Jun 2012 11:56 AM |
WHY U CALLING MEH GUY????
I ment that there's new things such as chapters. I was looking forward for more chapters. :D Also, add a camera manipulation tutorial. :D |
|
|
| Report Abuse |
|
|
|
| 21 Jun 2012 11:59 AM |
Ah, I called you guy because I didn't have the effort to press the back button to look at your name (sorreh). I might add a camera manipulation tutorial for Chapter 20, as that is quite advanced.
‹‹‹‹ Want to learn to script? http://wiki.roblox.com/index.php/Scripting_Book ›››› |
|
|
| Report Abuse |
|
|
kools
|
  |
| Joined: 11 Jan 2009 |
| Total Posts: 1659 |
|
|
| 21 Jun 2012 12:03 PM |
| :( I was reading that scripting book not quite that long ago. It stops at what ... Chapter 19 ? It was about to explain and go more into depth about string manipulation. |
|
|
| Report Abuse |
|
|
|
| 21 Jun 2012 12:16 PM |
Chapter 16, I've started to write it again. I'm almost done with chapter 16 :)
‹‹‹‹ Want to learn to script? http://wiki.roblox.com/index.php/Scripting_Book ›››› |
|
|
| Report Abuse |
|
|
Miro034
|
  |
| Joined: 07 Oct 2009 |
| Total Posts: 6568 |
|
|
| 21 Jun 2012 12:16 PM |
| I like your Name kools. And lego, are you planning of making chapters? |
|
|
| Report Abuse |
|
|
|
| 21 Jun 2012 12:25 PM |
What do you mean planning on making chapters? I've already start making more chapters, see my newest one:
http://wiki.roblox.com/index.php/Scripting_Book/Chapter_16
‹‹‹‹ Want to learn to script? http://wiki.roblox.com/index.php/Scripting_Book ›››› |
|
|
| Report Abuse |
|
|