Setting Different Walk Speed on guns Then No Guns

So, I’m trying to make it so if you have a glock you have 200 walk speed and with no glock 250. I tryed coding this but it didnt work what how did I go wrong?

Code:

weapon_glock/shared.lua


local function Test( ply )
	if ply.GetActiveWeapon then
	ply:SetWalkSpeed(200)
	if not IsValid( ply ) or not ply.GetActiveWeapon then 
		ply:SetWalkSpeed(250)
end