Make a player stop moving when reloading?

Ok so I’m working on a SWEP that, in my opinion, should make the player stop moving when the player reloads. Can someone help me with this?

Quick tip, when looking for a way to do something to a player go to the wiki and take a look at both the Player and Entity page (Because all Entity functions can be used on a player). Most of the time what you want is already a function… In this case, Player.Freeze. :smile:

How would I make the example code work only on the player that’s reloading the swep?


as the wiki search function is kinda shit and a pain to find stuff with use saves me a lot of time

What I’d do is:

function SWEP:Reload()

 local newvel = self.Owner:GetVelocity() * -1; -- Inverse of players velocity
 self.Owner:SetVelocity( newvel ); -- Add negative x, newvel, to positive x, their velocity, getting 0.


That would stop him for about a frame.:smile:

Which is exactly what he wants to do.

What if you set the run and walk speed to 0 at reloading and put them back to normal when it’s done? Freezing the player would keep him there if his ground fell away or he reloaded mid-jump (although you could of course add code to prevent the latter).

Or to prevent this you could add a chek to see if the player is on the ground before he can reload.