So, my question isn’t really an issue and more so a heads-up on whether what I’m doing is good practice and the optimal way to handle things.
Specifically, I’m looking into the most optimal way to translate client-sided inputs to a server-sided combat script. I want to know if what I’m doing is the best way to achieve the fastest possible response time without taking a player’s ping into account.
Currently, how I’d handle inputs is by binding them client-sided via ContextActionService:BindAction(...)
and then executing checks and firing a remote in the function itself
example for the client side:
ContextActionService:BindAction("Dash", Dash, false, Enum.KeyCode[KeyBindData.Dodge])
local function Dash(ActionName, InputState, InputObject)
if ActionName == "Dash" then
RemotePath.Dash:FireServer()
end
end
-- this isn't actually a script in my game but just an example of how I'd usually structure things.
If there are any faster / better methods, please let me know.
Things I’ve tried already: (mostly just the no-brainer things)
- Reducing the number of passed arguments within the remote event
- Handling the input over a remote that passes it to a server script that has specifically defined functions
example:
RemotePath.Remote.OnServerEvent:Connect(function(Player, Action, ...)
if Actions[Action] then
Actions[Action](Player, ...)
else
return
end
end)
NOTE: For the thing I tried up here, I asked an AI to calculate which was faster and got told that handling it like that was faster, so most of the time I’ll structure my scripts like that