Help with making a player slower.

I am making a weapon that slows the player down while being shot, but I also want the effect to last for a short time after them taking the shot. How would I go about doing that?

Here is what I have already.


         local slowvar = 2
         local vel = self:GetOwner():GetEyeTrace().Entity:GetVelocity()
         local velx = self:GetOwner():GetEyeTrace().Entity:GetVelocity().x
         local vely = self:GetOwner():GetEyeTrace().Entity:GetVelocity().y
         local velz = self:GetOwner():GetEyeTrace().Entity:GetVelocity().z
         self:GetOwner():GetEyeTrace().Entity:SetVelocity(Vector(velx / -slowvar, vely / -slowvar, velz / -slowvar))

You don’t need any of that code, use

Player:SetWalkSpeed, there is also SetRunSpeed, you can use a timer to delay the un-slowification.