So for a combat system I’ve been using many boolvalues to manage different states the player would currently be in like this: (Located under StarterCharacterScripts)
The reason I did this, is because I want the player to do some things only under specific conditions and I need them accessible for different scripts so I thought that would be the easiest way to handle this. But just recently I’ve realized that this isn’t really a good solution since apparently it’s not really save and there are better ways to deal with this.
What I need help with now is that I can’t really find a suitable solution to manage these states. I came up with different options but I’m not really sure in which direction to go, so I’ll list some of these here including my doubts about them.
Option 1:
Having a seperate module in ServerScriptService that saves these states and handles them like this:
local StateManager = {}
function StateManager:addState(player, state)
states[state][player] = true
end
function StateManager:removeState(player, state)
states[state][player] = nil
end
function StateManager:setState(player, state, value)
states[state][player] = value
end
function StateManager:returnState(player, state)
return states[state][player]
end
return StateManager
local States = {
["Stunned"] = { };
["KnockBack"] = {};
["Grounded"] = {};
["Blocking"] = {};
["Dodging"] = {};
...
}
return States
The thing here is I need some of these for the client too to check if the player is allowed to perform a certain move so I’d need to use remoteFunctions to get the desired state but the input would feel slow.
Option 2:
The same as Option 1 but the module is located in ReplicatedStorage so the client and server can easily get and change the states they need. Here my question is, if exploiters would have access to that and if that would be save?
Option 3
Seperating certain states I only need for the client in a seperate module than the ones I only need for the server but there would be still some I need for both…
Maybe all the option I just suggested are also bad and there are much better ways to solve this or maybe I’m also overthinking this all too much and don’t need most of these, which is a bad habit of mine, I’d really be glad if you guys could help me with this cuz it’s been bugging me for a while