Hitbox Collision On Client; Issues With Setting Attack State on Character

Hello, developers! I need help with client-server communication. Basically I have a StateEngine ModuleScript which handles the players Attacking State, so I know when to return the function if an exploiter were to try using multiple moves at once; and it looks something like this:


And the Use-Case for this ^ is right here:
image
Now couple of lines down from here is the Hitbox Collision register:
image
The issue with all this that I’m showing you guys is that:

  1. UsingMove function networks the state to Server long before Hitbox registers the target.
  2. With that, I’m unable to check for UsingMoves on server.
  3. Means that an exploiter will be able to use multiple moves if he wanted to.

If you know how I can solve my issue, please help by replying below. I’m hoping my issue isn’t too advanced for you devs to help me out. Thank you!

1 Like

I really need help with this. Bump

1 Like

I’m bumping my post again, i really need help with this.

Instead of calling the module directly from your client script, a more robust approach would be to encapsulate the necessary information in a structured table and fire a remote event to the server. So the client would have something like:

local function onBasicAttack()
    local info = {
        Ability = "BasicAttack",
        Name = "Punch",
        TimeEntered = workspace:GetServerTimeNow()
        MovesetInfo = {
            Basic = {
                BasicAttack = {
                    UsingMove = 2 
                }
            }
        }
    }
    
    EngineEvent:FireServer("AddUsingMove", info) 
end

Then on the server handle all the logic and call the module script:

EngineEvent.OnServerEvent:Connect(function(player, action, info)
    if action == "AddUsingMove" then
        local Character = player.Character
        if not Character then return end

        if StateEngine.PlayerEffectTags[Character] and StateEngine.PlayerEffectTags[Character].AddedUsingMoves then
            local CharacterEffectsTable = StateEngine.PlayerEffectTags[Character].AddedUsingMoves
            if not CharacterEffectsTable.UsingMove then
                StateEngine.AddUsingMove(Character, info)
            else
                warn(player.Name .. " attempted to use multiple moves at once!")
            end
        else
            StateEngine.AddUsingMove(Character, info)
        end
    end
end)