Making Weapon Mute/Gag Player When Shot?

So basically I have this gun that I got off the workshop (Thriller)
I want to make it so when someone is shot by it they can’t speak or type. I have seen this with other weapons so I know its possible and Im sure all it needs is a hook, I’m not that good at coding so I need someones help (Im sure its just a couple lines of code.). If you’re going to be rude about it please go somewhere else. K Thanks.
I appreciate anyone that is actually willing to help.

GM:PlayerSay

GM:PlayerCanHearPlayersVoice

I tried putting


hook.Add( "PlayerCanHearPlayersVoice", "Maximum Range", function( listener, talker )
	if listener:GetPos():Distance( talker:GetPos() ) > 0 then return false end
end )

at the end of the code. Will that stop voice chat of the person that is shot?

Did you test it?

Did you try to read and understand that code? We won’t spoon feed on you if you don’t try

I’m guessing you pulled the code from online somewhere.
While I agree with gonzalolog, I’ll give you a little idea.

You are not testing the distance of the two people, but if they have been shot by your weapon.
You’ll have to get creative with the weapon’s code.

Maybe make a local table that includes all the victims and use table.HasValue() or something similar.

[editline]11th October 2017[/editline]

Or even better
talker:GetNWBool()
tallker:SetNWBool()