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
 

Gun help

Previous Thread :: Next Thread 
dailyUSERNAME is not online. dailyUSERNAME
Joined: 16 Feb 2012
Total Posts: 15
27 Dec 2012 08:19 PM
I have a question about this peice of code:

function fire(v)

Tool.Handle.Fire:play()


local vCharacter = Tool.Parent
local vPlayer = game.Players:playerFromCharacter(vCharacter)

local missile = Instance.new("Part")



local spawnPos = vCharacter.PrimaryPart.Position



spawnPos = spawnPos + (v * 8)

missile.Position = spawnPos
missile.Size = Vector3.new(1,1,1)
missile.Velocity = v * 100
missile.BrickColor = BrickColor.new(colors[math.random(1, #colors)])
missile.Shape = 0
missile.BottomSurface = 0
missile.TopSurface = 0
missile.Name = "Paintball"
missile.Elasticity = 0
missile.Reflectance = 0
missile.Friction = .9

local force = Instance.new("BodyForce")
force.force = Vector3.new(0,90,0)
force.Parent = missile

Tool.BrickCleanup:clone().Parent = missile

local new_script = script.Parent.Paintball:clone()
new_script.Disabled = false
new_script.Parent = missile

local creator_tag = Instance.new("ObjectValue")
creator_tag.Value = vPlayer
creator_tag.Name = "creator"
creator_tag.Parent = missile



missile.Parent = game.Workspace

end

If you can see in this code there is the vaqriable spawnpos. Now there is a line saying spawnpos = spawnpos + (v*8). what is v? More importantly why isnt the function run on the mouse!


dailyUSERNAME
Report Abuse
dailyUSERNAME is not online. dailyUSERNAME
Joined: 16 Feb 2012
Total Posts: 15
27 Dec 2012 08:20 PM
Disected for the paintball gun. I get HOW the guns work just not why the function is run on v, and what is "v".
Report Abuse
adark is not online. adark
Joined: 13 Jan 2008
Total Posts: 6412
27 Dec 2012 08:25 PM
v is the argument passed to the function when fire() is called.
Report Abuse
dailyUSERNAME is not online. dailyUSERNAME
Joined: 16 Feb 2012
Total Posts: 15
27 Dec 2012 10:39 PM
Define what v does plz.
Report Abuse
adark is not online. adark
Joined: 13 Jan 2008
Total Posts: 6412
28 Dec 2012 12:27 AM
Hard to guess without knowing what data type v is. Check to see what is passed when the function is called and post it here.
Report Abuse
dailyUSERNAME is not online. dailyUSERNAME
Joined: 16 Feb 2012
Total Posts: 15
28 Dec 2012 12:17 PM
Ok I will
Report Abuse
LiamScerri is not online. LiamScerri
Joined: 10 Oct 2010
Total Posts: 560
28 Dec 2012 12:20 PM
In this paintball script,
v is the direction of where you are aiming in Vector3.
Report Abuse
dailyUSERNAME is not online. dailyUSERNAME
Joined: 16 Feb 2012
Total Posts: 15
28 Dec 2012 12:22 PM
Hard to understand, So "v" can be used in any script to define the direction where you are aiming at.
Report Abuse
dailyUSERNAME is not online. dailyUSERNAME
Joined: 16 Feb 2012
Total Posts: 15
28 Dec 2012 01:09 PM
Hmm. Better leave off the gunscripts until I get done building the map!
Report Abuse
adark is not online. adark
Joined: 13 Jan 2008
Total Posts: 6412
28 Dec 2012 01:56 PM
Ooh, now I understand.

When the fire() function is called, the script gets the unit vector of where you are aiming, and then the fire function takes that unit vector and goes out along it 8 units, so that the paintball doesn't hit the gun when firing.
Report Abuse
dailyUSERNAME is not online. dailyUSERNAME
Joined: 16 Feb 2012
Total Posts: 15
28 Dec 2012 05:17 PM
Ok. But can I use "v" to set vector in ANY script.
Report Abuse
dailyUSERNAME is not online. dailyUSERNAME
Joined: 16 Feb 2012
Total Posts: 15
28 Dec 2012 05:19 PM
I understand the script now. BUT not what "v" is.
Report Abuse
GhostSailor is not online. GhostSailor
Joined: 02 Jul 2010
Total Posts: 1913
28 Dec 2012 05:25 PM
v is a variable passed on to the function. It could be "tehvelecccityoftehammmmmmmmmmmmer" for all the script cares, as long as it is named consistently.

-~Obly of C&G~-
Report Abuse
dailyUSERNAME is not online. dailyUSERNAME
Joined: 16 Feb 2012
Total Posts: 15
28 Dec 2012 05:34 PM
Oh, Silly me. Well a variable that has no value and consists of a value :P. Thanks
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