Client command?

I write “/zedu” and the command it’s in the server console, how do I make it to the console of whoever puts it?

hook.Add( "PlayerSay", "abrirmenu", function( ply, text, public )
	text = string.lower( text )
	if ( text == "/zedu" ) then
		RunConsoleCommand( "openzedu" )
		return ""
end )

That would just run the command serverside. If you want that client to run the command use instead


There’s really no need to do this stuff serverside, everything can be done on client:

hook.Add("OnPlayerChat", "abrirmenu", function(plr, txt)
    if txt:lower() == "/zedu" then
        if plr == LocalPlayer() then RunConsoleCommand("openzedu") end
        return true

You can also use string.Trim and string.StartWith to make it better, like so:

if string.StartWith(string.Trim(txt:lower()), "/zedu") then

It’s way better to do so on the server simply because you can actually verify what they say, and I prefer handling anything command wise serverside.

Zedu try using this ( ) so that way it runs the console command on the player.

Why exactly do you think a command that does not require any communication with server whatsoever should be handled on server? I didn’t quite understand the meaning of ‘actually verify what they say’.

I’m going off of experience with commands that need to be more secured so it’s mainly my preference.

Plus on serverside PlayerSay you can stop the message from coming through just by returning “”, whereas you’d have to do a bit more to stop it from coming through OnPlayerChat.

On top of that I always worry about people overriding other OnPlayerChat hooks that utilize it for chat tags, name colors, etc. PlayerSay means you won’t risk messing with that.