Roblox's Official "Weapons Kit" breaks when placing weapons system into ReplicatedStorage

Hey,

I am attempting to use Roblox’s official Weapons Kit, which is available from the Toolbox. Here’s the page explaining its usage on the Roblox Developer website. I believe that these were added as part of Roblox’s recently-released Battle Royale kit, but are also intended for use separate from this kit. These premade Tools work as expected when being either picked up by the player, or when they are placed in the StarterPack. They also work as expected when tweaking various variables or when replacing the meshes themselves.

However, the page linked above recommends moving the WeaponsSystem folder included within each weapon into ReplicatedStorage - this makes sense, of course - especially since otherwise, the entire framework for all of the weapons is duplicated within each weapon (although having the framework stored locally in just one weapon still allows all other weapons to function as expected).

Moving this folder into ReplicatedStorage and removing it from inside any of the weapons in the Workspace or StarterPack results in the scripts within the folder not running - for example, the custom camera system and player animations for walking which had before been present on just spawning in are not there - and the weapons which are connected to these scripts disappear from the Workspace after 1 or 2 seconds of gameplay (as visible in the Explorer window). What gives? I don’t have much experience with the Roblox platform and am not fully familiar with how scripts stored through various services such as ReplicatedStorage interact with objects in the workspace, for example, but I had assumed that this would “just work” since I followed the instructions from the official Developer website (and yes, this is a reproducible problem and has been tested on multiple blank Studio projects).

I would greatly appreciate any help with this!

9 Likes

You hit the nail on the head with your analysis of what the script does in my thread where you got my attention. It has been a while since I did it for myself so I copied the WeaponsSystem folder into ReplicatedStorage and put the ServerWeaponsScript in ServerScriptService to redo it and figure it out.

It doesn’t work due to a small oversight on lines 54 and 60 inside of ServerWeaponsScript. The code inside of those conditionals is necessary to make the weapons system work but they never run if we have a weapons system folder and ServerWeaponsScript is in ServerScriptService from the start. All I did was pull the code in the block at line 60 out of the conditional and delete some unused variables like curWeaponsSystemFolder. Be sure to delete any copies of the WeaponsSystem. I didn’t test what would happen if you have copies but I don’t expect it to be very pretty.

The whole kit is full of these sort of oversights that add up to something that isn’t really easy to play with in a game. Deadlines might have been rough. But it is still a fantastic resource with a lot of really useful things to learn from nonetheless I learned a ton from it myself. If you spend a while debugging and customizing it you will eventually be left with a really nice fun and modular system. Just know that the page you linked doesn’t always get things right and this is not the last time you are gonna need to fix some weird mistake in the system.

And because I forgot to answer your last question on why the scripts arent running in ReplicatedStorage: scripts only run when put in certain places. Scripts will not run inside of ReplicatedStorage or ServerStorage. And where you run a script depends on what type of script it is. LocalScripts only run when they are in a players Backpack, character model, PlayerGui, PlayerScripts, or ReplicatedFirst. And Scripts will only run if they are a child of the workspace or ServerScriptService (which is why I put ServerWeaponsScript there). I recommend keeping these three pages bookmarked for quick reference while you are getting the hang of things: LocalScript, Script, ModuleScript.

Hope this helps!

12 Likes

Thanks so much! It worked perfectly. Do you think it would be something feasible or worth doing to turn this into first-person camera? I’m not sure how much this would change things - if it’s a first person camera, I would probably be using a seperate arms mesh, for example. Technically speaking, I’m all good with custom animation and models and all that, I’ve been using Blender for years, but would making this work in first person only be a matter of just editing some modulescripts for the camera movement, or is it not worth trying to convert?

1 Like

That is actually what I have already done to mine. I removed the PlayerCamera module entirely and wrote two new modules in its place. One controls the players camera telling it what to focus on for like menus and spectating, and the other creates and manages a viewmodel (that separate arms and weapon mesh you mentioned) as well as letting the camera module tell it when to show and hide. There are a lot of different ways you can do this. I will let you search the dev forum since there are a lot of different tutorials for making viewmodel. But for example, mine copies the players character and the gun, then it uses the players copied arms and poses them to grip certain attachments I added to the guns. Make sure to understand how the WeaponsSystem uses the different libraries on the client and the server. You should probably use a very similar structure to the existing PlayerCamera to make your code work.

5 Likes

I see you have experience with this KIT, is there a way to show the number of bullets remaining in a GUI or make them not infinite?
I’m doing a zombie survival, and this subtracts gameplay / difficulty.
I would appreciate your help.

Hello, I think this is relevant to bump for. I do not know if this has been tested recently but when I copy a weapon from this kit to the player’s backpack the weapon doesn’t show up in the player’s hand. What gives? I followed all instructions and I put the server script in ServerScriptService like this thread said to do.

1 Like