generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Barrage Spell only works on one enemy?

Previous Thread :: Next Thread 
1pie23 is not online. 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 is not online. 1pie23
Joined: 11 Jul 2010
Total Posts: 1865
20 Jun 2012 03:50 PM
Anyone.... MNN... anyone....
Report Abuse
legokid135 is not online. legokid135
Joined: 23 Jan 2009
Total Posts: 1470
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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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
Swordphin123 is not online. Swordphin123
Joined: 09 Apr 2008
Total Posts: 5234
20 Jun 2012 04:13 PM
^ Lol.
Report Abuse
1pie23 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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
legokid135 is not online. legokid135
Joined: 23 Jan 2009
Total Posts: 1470
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 is not online. 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
legokid135 is not online. legokid135
Joined: 23 Jan 2009
Total Posts: 1470
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 is not online. 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
legokid135 is not online. legokid135
Joined: 23 Jan 2009
Total Posts: 1470
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 is not online. 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
legokid135 is not online. legokid135
Joined: 23 Jan 2009
Total Posts: 1470
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image