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: Making an NPC shoot rockets out of their arm

Previous Thread :: Next Thread 
im2awsm is not online. im2awsm
Joined: 25 Aug 2010
Total Posts: 2295
09 Mar 2014 10:50 PM
So I'm trying to make an NPC which shoots rockets out of their arm. I borrowed scripts from the Linked Rocket Launcher script, but don't quite understand it, and can't get it working. (Rocket is defined, it is a brick)

function blow(hit, missile)
if missile == nil then return end
explosion = Instance.new("Explosion")
explosion.Position = missile.Position
wait(.1)
if missile then missile:Remove() end
end

function computeDirection(vec)
local lenSquared = vec.magnitude * vec.magnitude
local invSqrt = 1 / math.sqrt(lenSquared)
return Vector3.new(vec.x * invSqrt, vec.y * invSqrt, vec.z * invSqrt)
end

function fireRocket(vTarget)
local direction = game.Workspace.SandGuardian["Left Arm"].CFrame.lookVector
direction = computeDirection(direction)
local missile = Rocket:clone()
local pos = game.Workspace.SandGuardian["Left Arm"].Position + (direction * 10.0)
missile.CFrame = CFrame.new(pos, pos + direction) * CFrame.Angles(math.pi/2, 0, 0)

local floatForce = Instance.new("BodyForce")
floatForce.force = Vector3.new(0, missile:GetMass() * 196.1, 0.0)
floatForce.Parent = missile

missile.Velocity = direction * 20.0

missile.Parent = game.Workspace

missile.Touched:connect(function(hit) blow(hit, missile) end)

game.Debris:AddItem(missle, 10)
end
Report Abuse
b3njam1n is not online. b3njam1n
Joined: 05 Nov 2007
Total Posts: 19389
09 Mar 2014 11:30 PM
okay
Report Abuse
transIate is not online. transIate
Joined: 20 Jun 2013
Total Posts: 2699
09 Mar 2014 11:38 PM
lol

Place0
Place1

wiki it
Report Abuse
im2awsm is not online. im2awsm
Joined: 25 Aug 2010
Total Posts: 2295
09 Mar 2014 11:44 PM
bump
Report Abuse
transIate is not online. transIate
Joined: 20 Jun 2013
Total Posts: 2699
09 Mar 2014 11:46 PM
did u hear wat i said
Report Abuse
im2awsm is not online. im2awsm
Joined: 25 Aug 2010
Total Posts: 2295
09 Mar 2014 11:57 PM
Yeah. It didn't help at all.
Report Abuse
transIate is not online. transIate
Joined: 20 Jun 2013
Total Posts: 2699
10 Mar 2014 12:04 AM
o sry
Report Abuse
im2awsm is not online. im2awsm
Joined: 25 Aug 2010
Total Posts: 2295
10 Mar 2014 12:26 AM
ye u bedr b sorey
Report Abuse
transIate is not online. transIate
Joined: 20 Jun 2013
Total Posts: 2699
10 Mar 2014 01:12 AM
don't balktalk bme
Report Abuse
DiamondBladee is not online. DiamondBladee
Joined: 24 Feb 2013
Total Posts: 3527
10 Mar 2014 04:28 AM
You know where the activated event is? Like, the function towards the bottom that fire when a player clicks? Make it fire every 7 seconds (the reload time) by using a while loop or something.

As for the aiming, you need to find the nearest player's torso.
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