Setting walk/run speeds for specific weapons.

I am trying to set the walk/run speed to be slower when a weapon, such as the Sledge Hammer, is equipped. I’ve tried a ton of commands with no success. I’m attempting to put it as an “if” statement in the init.lua file for my game mode. A few times i even attempted to put it in the coding for that weapon, but with no success. Please if someone knows a way to change the walk/run speed when a specific weapon is equipped, i’d very much appreciate it. Thanks in advance.

**[Gamemode.Think

http://wiki.garrysmod.com/favicon.ico](wiki.garrysmod.com/?title=Gamemode.Think)**
**[Player.GetActiveWeapon

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Player.GetActiveWeapon)**
**[Player.SetWalkSpeed

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Player.SetWalkSpeed)**
**[Player.SetRunSpeed

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Player.SetRunSpeed)**

How would i get that to work for the sledge hammer only?

I atually just did something like this
I dont think its the most efficiant way but it works
[Lua]
function CLASS:Think( pl )
local wep = pl:GetActiveWeapon()
if(pl:Alive()) then
if(wep:GetClass() == “weapon_knife”) then
pl:SetWalkSpeed(250)
else
pl:SetWalkSpeed(200)
end
end
end
[/Lua]thats basically saying that if the player has a knife fun faster else run normal speed

[editline]12:36PM[/editline]

Oh and this is for fretta so You might have to change it slightly for a just a normal gamemode

If it’s an SWEP, you’re better off doing it in SWEP:Deploy and SWEP:Holster.

Read my post.