How I could handle Combat System like this?

Hello!
I was wondering how I could handle Combat System similiar to the one from Bleeding Blades.
For the first thought I wanted to make one big script and use UserInputService, and check what weapon player is holding, if it’s melee or fists, it attacks in certain direction, but if it’s bow, it just fires remote event with the mouse position. Some weapons like spears has the ability to be throwable and player can make them throwable by pressing X key.
For the second thought I wanted to use Tools and script each weapon, but I would have to make the function that changes attack/block directions in every melee weapon.

Should I use UserInputService and make one big script or use Tools and script each weapon?
Or are there any better ways to handle it?

Sorry for my english :neutral_face:

1 Like

Your english is great, thank you for posting on the devforums for help.

As for both your options…

While a big script can be easily accessed, you can not manage every single weapon inside (Without difficulty).

I recommend scripting each weapon, as it may seem tedious to search for weapons, but it is easier other than scrolling endlessly in a giant script, unless you are considerate with function names and able to search for keywords in scripts relatively easy.

I’ve heard of Module Scripts to be an alternative for big UserInputService system scripts, separating certain parts and functions into separate Module Scripts.
But if you’re not willing to learn anything new it is not a problem either.

But if there are any other developers who share different opinions, a follow up is appreciated.

1 Like

a decently organized, slightly inefficient way I would tackle this is:

  • one main server script that runs through most of the games code
    • multiple module scripts handling each weapons attack abilities and such, accessible through the main script.

your English was just perfect :slight_smile:

1 Like

You should definitely use UserInputService and one big script because you can use module scripts to integrate this seamlessly. Let me show you what I mean

  1. Place one chunky local script in StarterPlayerScripts that handles all input
  2. Have module scripts for each way of attacking eg. Melee Module, ShootingModule, ThrowingModule
  3. Require them all in the local script to keep everything nice and simple :smiley:
2 Likes

i would use a localscript placed in startercharacterscripts that handles whenever a tool gets added in the character, when a tool gets removed from the character, and when any input gets registered by userinputservice. now for each tool you are going to add in the game, make a values folder inside the tool with values (like boolvalues, numbervalues) in them so each tool is customizable, i would add a tooltype value that is a stringvalue which refers to what the tool is, for example : gun, spear, knife. i would get access to those values when the tool gets added to the character and whenever an input registers, like the button for activating the tool, i would get the tooltype of the weapon, if the tooltype is a gun, i would access a gunmodule and fire a function from there.

then again i am a bit bad at scripting, but i still recommend using this, this helps me out when i have to make a huge arsenal of weapons and scripting them one by one is just not ideal.