I have a CommandAttributed function that is usually called form a client. After the client disconnected, I want the server to call that exact same function. From the docs of ServerAttribute it says:
This would be redundant for [Command]
functions, as being server-only is
already enforced for them
This makes me wonder why calling a Command from a client with authority is fine, but calling the same function on the server generates an error?
Why do I have to implement the same function twice?
Well, Command and ClientRPC methods are handled in a special way. They are RPC methods. Commands can only be called by clients and executed on the server to tell the server what they want and ClientRPCs can only be called by the server and are executed on the clients. You should see Commands and ClientRPCs as communication elements.
The Server attribute has nothing to do with RPCs in the first place. It just ensures the method can only be executed on the server.
You may keep the body of Command and ClientRPCs rather short. You can create a private method with the Server attribute which does the actual work and just call that method from your Command method.