How do i make custom jumping function

Making a jumping function so i can manage movement/physics as i want.
but the problem is it seems to be a bit buggy when holding a space key to make character jump continuously
image


But i want make it more smooth
code

    if self.OnGround and DateTime.now().UnixTimestampMillis - self.LastTimeJumped > 100 then
        local vel = char.PrimaryPart.AssemblyLinearVelocity --char.PrimaryPart:GetVelocityAtPosition(char.PrimaryPart.Position)
        char.PrimaryPart.AssemblyLinearVelocity = vel * Vector3.new(1,0,1) + Vector3.new(0,50,0)
        self.LastTimeJumped = DateTime.now().UnixTimestampMillis
    end