I have not looked into details, but don't think that your code can work. You must always check the event_type in a server or client event. Also parts of your code are never executed because "server" or "client" are nowhere defined.