Need help with combat system (solved)

I need advice on my combat system. So it was already established on this post that it should be server sided to prevent exploiting. Another plus to server sided has to do with the tutorial im following (linked below). In the tutorial he has it all in a local script (client sided), meaning no one in the server would see what’s going on. The solution to all of this is making the script server sided. However this raises an issue, how am I supposed to bind the combat functions using context action service if the script is server sided? (Watch the video to see what I mean)

Roblox Sword Combat Tutorial Part 1 - YouTube

Should a combat system be in local or server scripts

Any suggestions or help on how to make it so I can bind the combat using contextactionservice is greatly appreciated!

You can use remote events.

They allow you to send data, objects, etc, to the server or client.

What you would want to do is in the local script make this fire to the server. Then on the server when it receives the event it will do that attack or whatever! Hope this helps!

Im making the combat script server sided. How would I be able to bind context action service to the script if it’s server sided? (Btw it’s server sided so the server sees everything)

Okie here is a run down.
A server script can not figure out if someone uses ContextActionService.
You have to do that in a local script.

Then fire an event to the server, a server script cant detect these things. It can tell if a player:

  • Clicks on there screen
  • Press a button on there keyboard
  • Get there mouse position
  • Find out if they press a Mobile button.
  • ETC

Only local scripts can do this sort of thing!

1 Like

Yes I know how that all works. What I’m saying is in the tutorial video he makes the entire combat system in a local script and sends data to the server. This is bad because exploiters can send data like damage and health to the server and it’s generally a buggy mess. So I’m moving the whole combat system to a server script, that way everyone can see everything. Is there some way I can send the functions in the combat system to the server and bind them using context action service? (Tl:dr - Combat System Server Sided, I want to be able to bind the functions in the system. To do this I need to somehow send the functions to a local script.)

Oh in that case.
Just store the damage and other values on the server. And just send the attack event:
Then you dont have to make the client send any values to the server!

1 Like

Okay so I’ll explain my combat system entirely, that might help.

Players have 4 weapons. A sword, Axe, Spear, and Hammer. I have these set up as tools because of this post (How to make a skin system like zo?). As tools I can simply change their models to change a skin.

So for damage I’m using this (Raycast Hitbox 4.01: For all your melee needs!) Pretty much im going to parent the raycast attachments to the tool and have them welded to the handle, that way no matter the skin, hitboxes are the same.

So this is how combat will work-
All 4 weapons are in the player’s Hotbar. When they equip a weapon it’ll weld it to their body and bind an unsheath action. When this unsheath action is fired it does multiple things. First it plays an unsheath animation and then when it hits a certain key frame in the animation it’ll destroy the body weld for the weapon and weld it to their hand. Then it unbinds the unsheath action, binds the sheath action, binds all the combat actions (attack, block, dash), unbinds sprinting, and also disabled the Hotbar, Then when a player press sheath it fires the sheath action, which essentially reverses everything.

I want the system to be seen by everyone. And since if it’s client sided then no one can see anything, hence I was switching it to the server to make my life a billion times easier.

“ Just store the damage and other values on the server. And just send the attack event:
Then you dont have to make the client send any values to the server!”

So, im 99% sure the raycasting part is server sided, so that’s handled. However I want every player to be able to see the combat system (anims, VFX, sheath/unsheath, attacks, blocking, etc). Any solutions?

This is a major ask … An entire re-wright of a code system we can’t even see. The only way anyone could help you here would be to work with the whole program, not just a few scripts. You may need to find someone to work with here. If not, you’ll need to verse yourself extensively on how to work with remotes. I’d be on the lookout for a program that is doing about the same thing as far as passing and working with data and the scripts. A working client/server system.

Have you actually tested that you can’t see all the VFX and anims on other clients? Because I think this tutorial is by Ampro (correct me if not) and he always uses client-server replication which would feature all clients seeing the VFX. If not, you may just be able to change a simple :FireClient() to a :FireAllClients() instead.

1 Like

Yeah turns out I was just being brain dead and didn’t realize it worked lol

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.