PlayerSay command crashes srcds after execution



hook.Add( "PlayerSay", "_BanningPlayer", function( ply, text )
	local input = string.Explode( " ", text );
	local BaseCommand = "!gban"
	local TimeArgument = tonumber( input[2] )
	local Reason = input[3]

	if ( input[1] == BaseCommand ) then
			if ( TimeArgument ) then
				if ( Reason ) then
				ply:Kick( "You have been banned for 
 "..TimeArgument.. "
 Reason: 
"..Reason )
				ply:Ban( TimeArgument )

			end
		end	
	end
end)


The above code works, it’s just that it crashes my scrds after I execute it


!gban 300 test

You’re kicking / banning the player that typed !gban. Also, if you execute Kick first, then the player is dropped from the server and may not be valid for the ban call. Typically a ban function should also handle the kick so one or the other should be needed but not both.

AFAIK Player:Ban doesn’t kick, he should swap the lines, first ban, then kick.