Creating New Guns - Nyemse/SPEARHEAD GitHub Wiki
Similar to other weapon systems, SPEARHEAD allows for any model in Roblox to be set up as a functional gun, albeit with some requirements.
WARNING: This tutorial assumes you've at least familiarized yourself with the basics of using Roblox Studio. If you haven't, I would recommend watching some tutorials or messing around in a blank game beforehand. You should at least know how to use the Explorer and Property windows, and the basic tools.
How to setup a new gun
- Start with placing a gun model in Workspace on some kind of flat surface, this will make it easier to set up the model.
- Grab one of the default gun models from SPEARHEAD, they're located in ReplicatedStorage > SPH_Assets > WeaponModels. You can use this model as a reference for what each part should look like and where it should be located.
- Make sure all parts inside your gun model are anchored.
The Tool
- Clone an existing SPEARHEAD tool, preferably one that's similar to the gun you're creating, and rename it to the same name as your gun model.
- Open the WeaponStats module, and configure the settings to your liking. For more information about each setting, visit the Tool Settings page.
- Place the tool in StarterPack if you'd like to spawn with it. The tool can also be used with any kind of locker or loadout system that uses Roblox tools.
The Grip
- Add a new part named "Grip" to the gun model, and preferably make it small and transparent. This part is typically placed close to the gun's trigger, but can be adjusted later if it doesn't look right in your character's hands. Make sure this part is facing the same direction as the gun.
A typical Grip placement for M4 derivative rifles.
- Grip parts house all of a gun's sound effects. They're required to have at least Fire, Echo, AimUp, AimDown, and Click sounds, but a plethora of other sounds can be included for animations.
- It's recommended to simply copy over sounds from another gun that's using the same animations, then change the ids to whatever you'd like.
- To explain, if an animation has a named keyframe of any kind, it will check if a corresponding sound can be found in the Grip part and play it if one is found. More information about animations and animation sounds can be found in the Creating Custom Animations page.
Grip Attachments
- Next, add two Attachment objects to the Grip part named "Muzzle" and "Chamber".
- Move the Muzzle attachment to the end of the gun barrel, and move the Chamber attachment to wherever the gun ejects its shells.
Typical Attachment positions
- The Muzzle attachment houses all visual fire effects. If you'd like to just copy over the muzzle effects from another gun, you can do so. If you'd like to create your own, visit the Model Customization page.
The AimPart
- Add a new part named "AimPart" to the gun model. This part is used as a reference point for lining up the sights and your camera.
- Lining up an AimPart can be difficult on some guns, so I trick I frequently use is to add a BlockMesh to the AimPart with a scale of 0.1,0.1,100. This can help get an idea of where the camera will be looking when aiming.
These settings on a BlockMesh will create a long line in the direction the AimPart is facing.
The Bolt
- If a part on your gun needs to move when you fire, name it "Bolt".
- If more than one part needs to move with the Bolt, you can also name these parts "Bolt" or add their names to the fireMoveParts setting in the gun's tool.
Finishing up
- Once you've finished setting up the model, place it in ReplicatedStorage > SPH_Assets > WeaponModels.
And now you're done! You should have a functional gun. If there are problems with it, visit the Troubleshooting page.