I want my weapon system to not have me change every script after the smallest of changes to the weapon system and maybe have options for a way of making weapons function without the roblox tool.
Currently the weapon system works by having a local script that handles the weapon logic in every single weapon (image example below), however I don’t want that as then I have to replace every single script for the smallest of tweaks, are there any options that wouldn’t require me to change every script but just 1?
Potentially you can use the CollectionService
Tag your all your guns with the same tag and you can script all the tagged objects the same.
local function setup_my_gun(gun: Tool)
-- put your gun script inside this function, replace
-- any `script.Parent` with `gun`
end
local CollectionService = game:GetService("CollectionService")
local my_gun_tag_name = "GunTool"
for _, inst in pairs(CollectionService:GetTagged(my_gun_tag_name)) do
setup_my_gun(inst)
end
CollectionService:GetInstanceAddedSignal(my_gun_tag_name):Connect(setup_my_gun)
The collection service will work for both, but you will still need a Script for server stuff and a LocalScript for client side stuff. Cannot make one script for both.
you can maybe place the script somewhere else. and have a separate script or code that clones that script and places it into tools during gameplay. dunno if this would work, havent tested.
It would work but script cloners would make certain anti-cheat measures that I have made not work correctly and have a lot of false-positives as I have tried to do that.
Along with the collection service, perhaps you should just make a Module Script that contains the gun logic. This way, you can reference the functions from any other script that calls the module.
Also, is there any reason you’re not handling the gun logic server-side?
I do handle most of the logic server-sided such as ammo, reloading and hitting targets, but the client script focuses on making ammo, reloading, firing and spread so that there is no delay and also client script is handling recoil as there would be a 2x delay because I need to send information to the server and back.