SWEP:Reload question

I want to open a menu with SWEP:Reload, but that function runs every tick you have the R key down.
How would I make it so it only runs it once?
I already tried using IsFirstTimePredicted()

Here is what I am using so far.


function SWEP:Reload()
	
	if ( IsFirstTimePredicted() and not self.Reloading ) then

		self.Reloading = true
		chat.AddText( "test" .. math.random( 1, 1000 ) )

	end

end

function SWEP:Think()

	if ( self.Reloading and IsValid( self.Owner ) and not self.Owner:KeyDown( IN_RELOAD ) ) then

		self.Reloading = false

	end
	
end

This code works if you tap R and hold it for a second, but if you just quickly tap it, the code runs 2-4 times.

Try just using



if CLIENT and IsFirstTimePredicted() and self.Owner:KeyPressed(IN_RELOAD) then bla() end


inside your reload function