Introduction to Weapons: Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>Clockwork
No edit summary
>KnKGames.Com
No edit summary
Line 1: Line 1:
{{CatUp|Tutorials}}
Attention Everyone: I did not phish Roni123’s acount! Someone hacked knkgames.com! Talk to Roni123 for more details!
I am permantly banned from roblox!


{{ScriptTutorial|Basic|Weapon}}
Please Spread The Word!


==Introduction==
This is a basic beginner's introduction to weapons. It explains to you the structure of weapons and why they work.


==Weapon Structure==
The structure of a weapon looks something like this.
<pre>
[Tool Name]
  |-Sounds
  |-Weapon Script
  |-Projectile Script
  |-Local Gui
  |-Handle
  |  |-Mesh
</pre>


The next few sections explain what this is.
Attention Everyone: I did not phish Roni123’s acount! Someone hacked knkgames.com! Talk to Roni123 for more details!
I am permantly banned from roblox!


===Tool===
Please Spread The Word!
The tool is the big thing at the top. It goes into people's backpacks and shows up in their screen. Tools have scripts, parts, and meshes that direct what the tool does. The only thing you really need to change in the tool is the name and the GripPos if you're trying to change how the player grips the weapon.


===Handle===
Attention Everyone: I did not phish Roni123’s acount! Someone hacked knkgames.com! Talk to Roni123 for more details!
The handle is the part that contains the mesh. Meshes can't be put into the game except under a part that defines its general shape (called the bounding box). The handle is the part that has a mesh in it that shows what the weapon looks like. Each weapon has its own mesh that it uses. Usually, if you want to make a new weapon, you should copy another existing weapon and change the script only so that you don't have to copy the mesh URLs and GripPos on the tool over.
I am permantly banned from roblox!


===Weapon Script===
Please Spread The Word!
The weapon script is usually called something related to the weapon name, such as "Server Launcher" for the Rocket Launcher and "Slingshot" for the slingshot. It dictates what the weapon does when its fired.


===Projectile Script===
Attention Everyone: I did not phish Roni123’s acount! Someone hacked knkgames.com! Talk to Roni123 for more details!
The projectile script is attached to the projectile and handles what the projectile does when it flies out of the weapon. Usually it just handles what happens when it hits something.
I am permantly banned from roblox!


===Local Gui===
Please Spread The Word!
The Local Gui is a [[RBX.lua.LocalScript|LocalScript]] that deals with cursors on the client. It changes the cursor to a target when you switch to a weapon and adds the "reloading" text onto the cursor after firing. Usually there is nothing that needs to be changed in this script except for the reload time.


===Sounds===
Attention Everyone: I did not phish Roni123’s acount! Someone hacked knkgames.com! Talk to Roni123 for more details!
You can't add sounds to your weapon, but you can take sounds from the other weapons.
I am permantly banned from roblox!


==How does the weapon work?==
Please Spread The Word!
Here's a step by step process of what happens when you select and use the rocket launcher. The rocket launcher tree looks like this:
Attention Everyone: I did not phish Roni123’s acount! Someone hacked knkgames.com! Talk to Roni123 for more details!
<pre>
I am permantly banned from roblox!
[LinkedRocketLauncher]
  |-Explosion - Sound
  |-Swoosh - Sound
  |-RocketScript - Projectile Script
  |-Server Launcher - Weapon Script
  |-Local Gui
  |-Handle
  |  |-Mesh
</pre>


Please Spread The Word!
Attention Everyone: I did not phish Roni123’s acount! Someone hacked knkgames.com! Talk to Roni123 for more details!
I am permantly banned from roblox!


{| border="1" cellspacing="1" cellpadding="5"
Please Spread The Word!
! Client !! Script
Attention Everyone: I did not phish Roni123’s acount! Someone hacked knkgames.com! Talk to Roni123 for more details!
|- valign="top"
I am permantly banned from roblox!
| Select the rocket from your weapons.
 
| '''Local Gui:'''
Please Spread The Word!
<pre>Tool.Equipped:connect(onEquippedLocal)</pre>
Attention Everyone: I did not phish Roni123’s acount! Someone hacked knkgames.com! Talk to Roni123 for more details!
This adds a listener that changes the cursor to a target cursor. The listener waits for "Equipped" and then goes to the "onEquippedLocal" function. <pre>
I am permantly banned from roblox!
mouse.Icon = "rbxasset://textures\\GunCursor.png"</pre>
 
The function changes the mouse icon.
Please Spread The Word!
|- valign="top"
Attention Everyone: I did not phish Roni123’s acount! Someone hacked knkgames.com! Talk to Roni123 for more details!
| Click on a target.
I am permantly banned from roblox!
| '''Local Gui:'''
 
The onButton1Down function has a [[Debounce]] system that keeps it from repeatedly activating.
Please Spread The Word!Attention Everyone: I did not phish Roni123’s acount! Someone hacked knkgames.com! Talk to Roni123 for more details!
<pre>
I am permantly banned from roblox!
mouse.Icon = "rbxasset://textures\\GunWaitCursor.png" 
 
wait(12)
Please Spread The Word!
mouse.Icon = "rbxasset://textures\\GunCursor.png"</pre>Changes the cursor to "reloading," waits until the weapon is done reloading (12 seconds) and then changes the cursor back to the regular one.
'''Server Launcher:'''
The script at the top makes the rocket but it doesn't fire it yet.<pre>
script.Parent.Activated:connect(onActivated)</pre>
This causes "onActivated" to run when the script.Parent, or the Rocket Launcher, is run. onActivated uses [[Debounce]] as well.<pre>
local targetPos = humanoid.TargetPoint
fire(targetPos)</pre>
This gets what the target is and then calls the fire function that will actually shoot the rocket. I won't go into what the fire function actually does, but the key things are:<pre>
local missile = Rocket:clone()
missile.RocketScript.Disabled = false
missile.Parent = game.Workspace</pre>
This makes a new missile from the Rocket at the top, activates its script (the projectile script) and puts it into the game.
|- valign="top"
| Rocket flies out and makes a whooshing noise.
| '''RocketScript:'''
<pre>swoosh:play()</pre>
This will play the sound that the rocket makes.
<pre>fly()</pre>
This causes the rocket to keep flying forward without falling due to gravity.
|- valign="top"
| '''RocketScript:'''
Rocket hits target, explodes, and blows up a person.
| <pre>connection = shaft.Touched:connect(blow)</pre>
This causes the rocket to blow up when it touches something by calling the blow function.
<pre>explosion = Instance.new("Explosion")
explosion.Position = shaft.Position
explosion.Parent = game.Workspace</pre>
This makes the explosion.
|}

Revision as of 06:13, 2 July 2008

Attention Everyone: I did not phish Roni123’s acount! Someone hacked knkgames.com! Talk to Roni123 for more details! I am permantly banned from roblox!

Please Spread The Word!


Attention Everyone: I did not phish Roni123’s acount! Someone hacked knkgames.com! Talk to Roni123 for more details! I am permantly banned from roblox!

Please Spread The Word!

Attention Everyone: I did not phish Roni123’s acount! Someone hacked knkgames.com! Talk to Roni123 for more details! I am permantly banned from roblox!

Please Spread The Word!

Attention Everyone: I did not phish Roni123’s acount! Someone hacked knkgames.com! Talk to Roni123 for more details! I am permantly banned from roblox!

Please Spread The Word!

Attention Everyone: I did not phish Roni123’s acount! Someone hacked knkgames.com! Talk to Roni123 for more details! I am permantly banned from roblox!

Please Spread The Word! Attention Everyone: I did not phish Roni123’s acount! Someone hacked knkgames.com! Talk to Roni123 for more details! I am permantly banned from roblox!

Please Spread The Word! Attention Everyone: I did not phish Roni123’s acount! Someone hacked knkgames.com! Talk to Roni123 for more details! I am permantly banned from roblox!

Please Spread The Word! Attention Everyone: I did not phish Roni123’s acount! Someone hacked knkgames.com! Talk to Roni123 for more details! I am permantly banned from roblox!

Please Spread The Word! Attention Everyone: I did not phish Roni123’s acount! Someone hacked knkgames.com! Talk to Roni123 for more details! I am permantly banned from roblox!

Please Spread The Word! Attention Everyone: I did not phish Roni123’s acount! Someone hacked knkgames.com! Talk to Roni123 for more details! I am permantly banned from roblox!

Please Spread The Word!Attention Everyone: I did not phish Roni123’s acount! Someone hacked knkgames.com! Talk to Roni123 for more details! I am permantly banned from roblox!

Please Spread The Word!