You can literally just fire a remote whenever the player presses any key. Then on the server, you can check his key.
You would only need one remote, then.
Too many remotes can be bad, but using only one for everything will be inefficient and confusing. Every ‘system’ or ‘task’ should get its own remote, i.e. one for inventory and shop-related stuff, one for the combat system, one for each vehicle, etc.
Yes, spamming remotes can cause lag too. Some people who make weapons use methods to work around it and reduce the number of events, like doing hit detection on the client, then having the server verify and take damage accordingly.
In other words, anything that is important should be done on the server, and if something doesn’t have to be sent through a RE, the client can do it instead.
Hmm. Soo. If im firing remote every time when player pressing key, will it do lag too?
uis.InputBegan:Connect(function(inp,pro)
if pro then return end
if inp.KeyCode == Enum.KeyCode.Unknown then
remotes.Keys:FireServer(inp.UserInputType, "Began")
else
remotes.Keys:FireServer(inp.KeyCode, "Began")
end
end)
uis.InputEnded:Connect(function(inp,pro)
if pro then return end
if inp.KeyCode == Enum.KeyCode.Unknown then
remotes.Keys:FireServer(inp.UserInputType, "Ended")
else
remotes.Keys:FireServer(inp.KeyCode, "Ended")
end
end)
It won’t make a noticeable difference. The most important factor is how much you’re sending, and how often. Don’t worry about using many separate RemoteEvent or RemoteFunction objects - keep it readable and understandable for yourself.
Firing a remote every time a player presses a key is fine. There are a few other threads about all of this, you should try searching to find some. There’s a lot of interesting behaviour of remotes that might help you.
You may need to worry about optimisation later if you notice any kind of lag, but typically you shouldn’t stress yourself about it too much, or else you end up over-optimising and making your code much more difficult to read.
Try to narrow down where you end up sending a lot of data to the clients or to the server. Too much data being sent to the clients can be just as bad as too much being sent to the server. Typically it’s worse, I think, since the roblox servers should be able to handle a lot more data than each client.